Fixes
- Added forgot option - added modify user - moved login and register
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
@{
|
||||
var controller = ViewContext.RouteData.Values["Controller"];
|
||||
var action = ViewContext.RouteData.Values["Action"];
|
||||
var controller = ViewContext.RouteData.Values["Controller"].ToString();
|
||||
var action = ViewContext.RouteData.Values["Action"].ToString();
|
||||
}
|
||||
|
||||
<div class="breadcrumb">
|
||||
@Html.ActionLink("Home", "Index", "Home")
|
||||
@if (controller.ToString() != "Home")
|
||||
@if (controller != "Home")
|
||||
{
|
||||
@:> @Html.ActionLink(controller.ToString(), "Index", controller.ToString())
|
||||
@:> @Html.ActionLink(controller, "Index", controller)
|
||||
}
|
||||
@if (action.ToString() != "Index")
|
||||
@if (action != "Index")
|
||||
{
|
||||
@:> @Html.ActionLink(action.ToString(), action.ToString(), controller.ToString())
|
||||
@:> @Html.ActionLink(action, action, controller)
|
||||
}
|
||||
|
||||
</div>
|
||||
@@ -1,33 +0,0 @@
|
||||
<ul style="list-style-type:none">
|
||||
<li class="user-header">
|
||||
<input type="text" id="username" placeholder="username" />
|
||||
<input type="password" id="password" placeholder="password" />
|
||||
<div>
|
||||
<button class="btn-default btn btn-flat" id="login-btn">Login</button>
|
||||
</div>
|
||||
<p id="msg" class="login-box-msg"></p>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<script>
|
||||
$("#login-btn").on("click", function () {
|
||||
var username = $("#username").val();
|
||||
var password = $("#password").val();
|
||||
$.ajax({
|
||||
url: "/Account/_login",
|
||||
data: { Username: username, Password: password },
|
||||
dataType: "json",
|
||||
type: "POST",
|
||||
success: function (data) {
|
||||
var msg = $("#msg");
|
||||
if (data.success) {
|
||||
window.location.reload();
|
||||
} else {
|
||||
msg.html(data.message).show();
|
||||
$("#user-menu").addClass("open");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
})
|
||||
});
|
||||
</script>
|
||||
@@ -1,138 +0,0 @@
|
||||
@inject IHttpContextAccessor HttpContextAccessor
|
||||
@inject IDataContextFactory<SeniorDataContext> dbFactory
|
||||
|
||||
@{
|
||||
var session = HttpContextAccessor.HttpContext.Session;
|
||||
var db = dbFactory.Create();
|
||||
var username = session.GetString("username");
|
||||
var patientData = db.Patients.Where(p => p.Username.Equals(username)).ToArray().FirstOrDefault();
|
||||
var hasDoc = patientData != null;
|
||||
}
|
||||
|
||||
<div class="content">
|
||||
<div class="pull-left" , style="width: 50%">
|
||||
<h2 class="alert-success" style="text-align:center">
|
||||
Welcome @username
|
||||
</h2>
|
||||
name: @session.GetString("name")<br />
|
||||
lastname: @session.GetString("lastname")<br />
|
||||
email: @session.GetString("email")<br />
|
||||
</div>
|
||||
|
||||
<div class="box pull-right" , style="width: 45%">
|
||||
@if (hasDoc) // is patient and has doc, must show doc data
|
||||
{
|
||||
var doctor = (from u in db.Users
|
||||
join d in db.Doctors on u.Username equals d.Username
|
||||
where d.Username.Equals(patientData.Doctor)
|
||||
select new { u.Username, u.Name, u.LastName, d.Location }).ToArray().First();
|
||||
|
||||
<p class="text-bold">Dottore: @doctor.Name @doctor.LastName</p>
|
||||
<p class="text-fuchsia">Dove mi puoi trovare? @doctor.Location</p>
|
||||
<textarea class="progress-text" placeholder="Nessuna nuova nota" readonly>@patientData.Notes</textarea>
|
||||
|
||||
<a class="" href="/Message/@doctor.Username">Invia un messaggio al tuo dottore</a>
|
||||
}
|
||||
else
|
||||
{
|
||||
dynamic[] data;
|
||||
Type type = null;
|
||||
string title = null;
|
||||
var docData = db.Doctors.Where(d => d.Username.Equals(username)).ToArray().FirstOrDefault();
|
||||
|
||||
if (docData != null) // is DOC
|
||||
{
|
||||
// see all the patient of the doc
|
||||
title = "Lista dei pazienti";
|
||||
var patients = (from u in db.Users
|
||||
join p in db.Patients on u.Username equals p.Username
|
||||
where p.Doctor.Equals(docData.Username)
|
||||
select new { u.Username, u.Name, u.LastName, p.Notes, Profile = "<a href=\\\"/user/" + u.Username + "\\\">Profile</a>" }).ToArray();
|
||||
data = patients;
|
||||
type = patients.FirstOrDefault()?.GetType();
|
||||
}
|
||||
else // is a patient and need to choose a doctor
|
||||
{
|
||||
// choose which doc you want
|
||||
title = "Scegli un Doc";
|
||||
var docs = (from u in db.Users
|
||||
join d in db.Doctors on u.Username equals d.Username
|
||||
select new { u.Username, u.Name, u.LastName, d.Location, Choose = "<a id=\\\"choose-" + u.Username + "\\\" href=#>Scegli</a>" }).ToArray();
|
||||
data = docs;
|
||||
type = docs.FirstOrDefault().GetType();
|
||||
}
|
||||
|
||||
if (type != null)
|
||||
{
|
||||
|
||||
var fields = new List<string>();
|
||||
|
||||
foreach (var field in type.GetProperties())
|
||||
{
|
||||
fields.Add(field.Name);
|
||||
}
|
||||
|
||||
<p>@title</p>
|
||||
<div id="var-table"></div>
|
||||
<script>
|
||||
var datas = [
|
||||
@foreach (var el in data)
|
||||
{
|
||||
@:{
|
||||
@foreach (var field in fields)
|
||||
{
|
||||
@field@:: "@Html.Raw(type.GetProperty(field).GetValue(el, null))",
|
||||
}
|
||||
@:},
|
||||
}
|
||||
];
|
||||
|
||||
$(document).ready(function () {
|
||||
$("#var-table").kendoGrid({
|
||||
dataSource: {
|
||||
data: datas,
|
||||
schema: {
|
||||
model: {
|
||||
fields: {
|
||||
@foreach (var field in fields)
|
||||
{
|
||||
@field@: : { type: "@field.GetType().Name" },
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
scrollable: true,
|
||||
sortable: true,
|
||||
filterable: true,
|
||||
columns: [
|
||||
@foreach (var field in fields)
|
||||
{
|
||||
@:{ field: "@field", title: "@field", template: "#=@field#" },
|
||||
}
|
||||
]
|
||||
});
|
||||
@if(docData == null) // choose a doc
|
||||
{
|
||||
<text>
|
||||
$('[id^="choose-"]').on("click", function () {
|
||||
var id = this.id.replace("choose-", '');
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/Account/_addDoc",
|
||||
data: { doctor: id },
|
||||
success: function (data) {
|
||||
if (data.success) {
|
||||
window.location.reload();
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
</text>
|
||||
}
|
||||
});
|
||||
</script>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,16 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
||||
namespace SeniorAssistant.Views.Shared
|
||||
{
|
||||
public class SuccessModel : PageModel
|
||||
{
|
||||
public void OnGet()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
<ul style="list-style: none">
|
||||
<li class="user-header">
|
||||
<input type="text" id="regUsername" placeholder="Username" required />
|
||||
<input type="text" id="regName" placeholder="Name" />
|
||||
<input type="text" id="regLastname" placeholder="Lastname" />
|
||||
<input type="password" id="regPassword" placeholder="Password" required />
|
||||
<input type="email" id="regEmail" placeholder="Email" required />
|
||||
<input type="text" id="regDoctor" placeholder="Doctor only (543210)" />
|
||||
<div>
|
||||
<button class="btn-default btn btn-flat" id="register-btn">Register</button>
|
||||
</div>
|
||||
<p id="msg-reg" class="login-box-msg"></p>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<script>
|
||||
$("#register-btn").on("click", function () {
|
||||
var username = $("#regUsername").val();
|
||||
var name = $("#regName").val();
|
||||
var lastname = $("#regLastname").val();
|
||||
var password = $("#regPassword").val();
|
||||
var email = $("#regEmail").val();
|
||||
var code = $("#regDoctor").val();
|
||||
|
||||
$.ajax({
|
||||
url: "/Account/_register",
|
||||
data: {
|
||||
Code: code,
|
||||
User: {
|
||||
Username: username,
|
||||
Name: name,
|
||||
Lastname: lastname,
|
||||
Password: password,
|
||||
Email: email
|
||||
}
|
||||
},
|
||||
dataType: "json",
|
||||
type: "POST",
|
||||
success: function (data) {
|
||||
var msg = $("#msg-reg");
|
||||
if (data.success) {
|
||||
window.location.reload();
|
||||
} else {
|
||||
msg.html(data.message).show();
|
||||
}
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
alert(error)
|
||||
}
|
||||
})
|
||||
});
|
||||
</script>
|
||||
@@ -1,16 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
||||
namespace SeniorAssistant.Views.Shared
|
||||
{
|
||||
public class RegisterModel : PageModel
|
||||
{
|
||||
public void OnGet()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,12 @@
|
||||
var session = HttpContextAccessor.HttpContext.Session;
|
||||
string search = HttpContextAccessor.HttpContext.Request.Query["q"];
|
||||
string username = session.GetString("username");
|
||||
|
||||
|
||||
if (username != null)
|
||||
{
|
||||
var isDoc = session.GetString("role").Equals("doctor");
|
||||
var MaxPatients = 30;
|
||||
var Menu = new List<IMenuItem>();
|
||||
Menu.Add(new MenuItem("Profilo", "/"));
|
||||
Menu.Add(new MenuItem("Dati personali", "/user/" + username));
|
||||
@@ -19,7 +21,18 @@
|
||||
where p.Doctor.Equals(username)
|
||||
join u in db.Users on p.Username equals u.Username
|
||||
select new { Username = p.Username, Name = u.Name + " " + u.LastName }).ToArray();
|
||||
var sub = new SubMenu() { Text = "Pazienti", Items = new List<MenuItem>() };
|
||||
|
||||
if(search != null)
|
||||
{
|
||||
patients = (from p in patients
|
||||
where p.Name.StartsWith(search)
|
||||
select p).ToArray();
|
||||
}
|
||||
|
||||
patients.Take(MaxPatients);
|
||||
|
||||
var num = patients.Count();
|
||||
var sub = new SubMenu() { Text = num + " pazienti link rapido", Items = new List<MenuItem>() };
|
||||
foreach (var p in patients)
|
||||
{
|
||||
sub.Items.Add(new MenuItem(p.Name, "/user/" + p.Username));
|
||||
@@ -32,7 +45,10 @@
|
||||
var patient = (from p in db.Patients
|
||||
where p.Username.Equals(username)
|
||||
select p).FirstOrDefault();
|
||||
Menu.Add(new MenuItem("Invia un messaggio al dottore", "/Message/" + patient.Doctor));
|
||||
if (patient != null)
|
||||
{
|
||||
Menu.Add(new MenuItem("Invia un messaggio al dottore", "/Message/" + patient.Doctor));
|
||||
}
|
||||
}
|
||||
<aside class="main-sidebar">
|
||||
<!-- sidebar: style can be found in sidebar.less -->
|
||||
|
||||
Reference in New Issue
Block a user