Compare commits

..

No commits in common. "6388899f8b69dceca6779992cf3dbbde9f1b0eb5" and "1c600e8d4d7078a890acba9289cb075df3903a8d" have entirely different histories.

8 changed files with 35 additions and 185 deletions

View File

@ -5,23 +5,20 @@ using System.Web;
using System.Web.Mvc; using System.Web.Mvc;
using System.Web.Routing; using System.Web.Routing;
namespace FIT5032_Assignment { namespace FIT5032_Assignment
public class RouteConfig { {
public static void RegisterRoutes(RouteCollection routes) { public class RouteConfig
routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); {
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
// Put Home folder into root route independently without keyword "Home" // Put Home folder into root route independently without keyword "Home"
routes.MapRoute( routes.MapRoute(
name: "Home", name: "Home",
url: "{action}", url: "{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
); );
}
routes.MapRoute(
name: "Actions",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
} }
}
} }

View File

@ -1,90 +0,0 @@
using System;
using System.Collections.Generic;
using System.Data.Entity.Core.Common.CommandTrees;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using FIT5032_Assignment.Models;
using System.Data.Entity;
using System.Diagnostics;
namespace FIT5032_Assignment.Controllers {
public class AppointmentsController : Controller {
private Database1Entities db = new Database1Entities();
// GET: Appointments
public ActionResult Index() {
return View();
}
// GET: Appointments/Details/5
public ActionResult Details(int id) {
return View();
}
// GET: Appointments/Create
public ActionResult Create() {
// Pass a dropdown list for all doctors
List<Doctors> doctors = db.Doctors.ToList();
// Create a tuple for put uuid and displayName into it
List<Tuple<string, string>> doctorsList = new List<Tuple<string, string>>();
List<Users> users = db.Users.ToList();
for (int i = 0; i < doctors.Count; i++) {
// Get displayName from users table
string displayName = users.Find(user => user.uuid == doctors[i].user).displayName;
Tuple<string, string> doctor = new Tuple<string, string>(doctors[i].user, displayName);
doctorsList.Add(doctor);
}
ViewBag.doctorsList = new SelectList(doctorsList, "Item1", "Item2");
return View();
}
// POST: Appointments/Create
[HttpPost]
public ActionResult Create(FormCollection collection) {
try {
// TODO: Add insert logic here
return RedirectToAction("Index");
}
catch {
return View();
}
}
// GET: Appointments/Edit/5
public ActionResult Edit(int id) {
return View();
}
// POST: Appointments/Edit/5
[HttpPost]
public ActionResult Edit(int id, FormCollection collection) {
try {
// TODO: Add update logic here
return RedirectToAction("Index");
}
catch {
return View();
}
}
// GET: Appointments/Delete/5
public ActionResult Delete(int id) {
return View();
}
// POST: Appointments/Delete/5
[HttpPost]
public ActionResult Delete(int id, FormCollection collection) {
try {
// TODO: Add delete logic here
return RedirectToAction("Index");
}
catch {
return View();
}
}
}
}

View File

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

View File

@ -184,7 +184,6 @@
<Compile Include="App_Start\BundleConfig.cs" /> <Compile Include="App_Start\BundleConfig.cs" />
<Compile Include="App_Start\FilterConfig.cs" /> <Compile Include="App_Start\FilterConfig.cs" />
<Compile Include="App_Start\RouteConfig.cs" /> <Compile Include="App_Start\RouteConfig.cs" />
<Compile Include="Controllers\AppointmentsController.cs" />
<Compile Include="Controllers\HomeController.cs" /> <Compile Include="Controllers\HomeController.cs" />
<Compile Include="Global.asax.cs"> <Compile Include="Global.asax.cs">
<DependentUpon>Global.asax</DependentUpon> <DependentUpon>Global.asax</DependentUpon>
@ -316,11 +315,8 @@
<Content Include="Views\Home\CompleteProfile.cshtml" /> <Content Include="Views\Home\CompleteProfile.cshtml" />
<Content Include="Views\Home\View.cshtml" /> <Content Include="Views\Home\View.cshtml" />
<Content Include="Views\Home\ImageUpload.cshtml" /> <Content Include="Views\Home\ImageUpload.cshtml" />
<Content Include="Views\Appointments\Index.cshtml" />
<Content Include="Views\Appointments\Create.cshtml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="Views\Default\" />
<Folder Include="Views\Test\" /> <Folder Include="Views\Test\" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -9,7 +9,7 @@
<IISExpressUseClassicPipelineMode /> <IISExpressUseClassicPipelineMode />
<UseGlobalApplicationHostFile /> <UseGlobalApplicationHostFile />
<LastActiveSolutionConfig>Debug|Any CPU</LastActiveSolutionConfig> <LastActiveSolutionConfig>Debug|Any CPU</LastActiveSolutionConfig>
<Controller_SelectedScaffolderID>MvcControllerWithActionsScaffolder</Controller_SelectedScaffolderID> <Controller_SelectedScaffolderID>MvcControllerWithContextScaffolder</Controller_SelectedScaffolderID>
<Controller_SelectedScaffolderCategoryPath>root/Common/MVC/Controller</Controller_SelectedScaffolderCategoryPath> <Controller_SelectedScaffolderCategoryPath>root/Common/MVC/Controller</Controller_SelectedScaffolderCategoryPath>
<WebStackScaffolding_ControllerDialogWidth>600</WebStackScaffolding_ControllerDialogWidth> <WebStackScaffolding_ControllerDialogWidth>600</WebStackScaffolding_ControllerDialogWidth>
<WebStackScaffolding_LayoutPageFile>~/Views/Shared/_Layout.cshtml</WebStackScaffolding_LayoutPageFile> <WebStackScaffolding_LayoutPageFile>~/Views/Shared/_Layout.cshtml</WebStackScaffolding_LayoutPageFile>
@ -22,8 +22,6 @@
<View_SelectedScaffolderID>MvcViewScaffolder</View_SelectedScaffolderID> <View_SelectedScaffolderID>MvcViewScaffolder</View_SelectedScaffolderID>
<View_SelectedScaffolderCategoryPath>root/Common/MVC/View</View_SelectedScaffolderCategoryPath> <View_SelectedScaffolderCategoryPath>root/Common/MVC/View</View_SelectedScaffolderCategoryPath>
<WebStackScaffolding_ViewDialogWidth>600</WebStackScaffolding_ViewDialogWidth> <WebStackScaffolding_ViewDialogWidth>600</WebStackScaffolding_ViewDialogWidth>
<_SelectedScaffolderID>MvcControllerEmptyScaffolder</_SelectedScaffolderID>
<_SelectedScaffolderCategoryPath>root/Common</_SelectedScaffolderCategoryPath>
</PropertyGroup> </PropertyGroup>
<ProjectExtensions> <ProjectExtensions>
<VisualStudio> <VisualStudio>

View File

@ -1,40 +0,0 @@
@model FIT5032_Assignment.Models.Appointments
@{
ViewBag.Title = "Create";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>Create</h2>
@using (Html.BeginForm()) {
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>Appointments</h4>
<hr />
<!-- Dropdown menu for select a doctor -->
<div class="form-group">
@Html.LabelFor(model => model.responsibleBy, "Select a doctor", htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.DropDownList("user.displayName", @ViewBag.doctorsList as SelectList, htmlAttributes: new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.responsibleBy, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Create" class="btn btn-default" />
</div>
</div>
</div>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}

View File

@ -1,11 +0,0 @@

@{
ViewBag.Title = "Appointments";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>Appointments</h2>
<ul>
<li><a href="./Create">Make a new appointment</a></li>
</ul>

View File

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