fix a problem for database has not saved changes

This commit is contained in:
Astrian Zheng 2023-10-17 16:10:27 +11:00
parent 1c600e8d4d
commit 7c747a583e
2 changed files with 19 additions and 18 deletions

View File

@ -334,7 +334,7 @@ namespace FIT5032_Assignment.Controllers {
}
// Check if the email have a patient profile
var db = new Database1Entities();
var dbEntity = new Database1Entities();
// Find the account associated with the email
var app_id = "ZHM5whW5xsZEczTn2loffzjN";
var url = $"https://api.passage.id/v1/apps/{app_id}/users?identifier={model.patientEmail}";
@ -344,13 +344,13 @@ namespace FIT5032_Assignment.Controllers {
return View(model);
}
var patientId = JsonConvert.DeserializeObject<PassageUserFindReply>(res).Users[0].Id;
var patientCredential = db.Credentials.Where(c => (c.uniqueIdCode == patientId) && (c.provider == 0));
var patientCredential = dbEntity.Credentials.Where(c => (c.uniqueIdCode == patientId) && (c.provider == 0));
if (patientCredential.Count() == 0) {
ModelState.AddModelError("patientEmail", "No patient found");
return View(model);
}
var patientUuid = patientCredential.First().user;
var patient = db.Users.Where(u => u.uuid == patientUuid);
var patient = dbEntity.Users.Where(u => u.uuid == patientUuid);
if (patient.Count() == 0 || patient.First().role != 1) {
ModelState.AddModelError("patientEmail", "No patient found");
return View(model);
@ -383,6 +383,7 @@ namespace FIT5032_Assignment.Controllers {
file = fileName,
status = 0,
};
db.SaveChanges();
// Send attached email with mailgun
var doctorName = user.displayName;

View File

@ -5,12 +5,9 @@
// cookie
if (Request.Cookies["psg_auth_token"] == null)
{
if (Request.Cookies["psg_auth_token"] == null) {
loginStatus = false;
}
else
{
} else {
loginStatus = true;
}
@ -20,12 +17,15 @@
@Scripts.Render("~/bundles/jqueryval")
}
@if (loginStatus)
{
@if (loginStatus) {
<img src="@ViewBag.avatar" alt="Avatar" style="width:200px" />
<h1>Welcome back, @ViewBag.displayname</h1>
<p><b>Email address</b> <span id="emailfield">john.appleseed@mac.com</span></p>
<p><b>Role</b> @ViewBag.role</p>
<hr />
<h2>Features</h2>
<p><a href="/MyImages">MyImages</a></p>
<hr />
<p><button id="logoutbutton">Log out</button></p>
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>