Find doctor

This commit is contained in:
Astrian Zheng 2023-10-17 18:05:39 +11:00
parent 7c747a583e
commit 6388899f8b
8 changed files with 167 additions and 18 deletions

View File

@ -5,18 +5,21 @@ using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
namespace FIT5032_Assignment
{
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
namespace FIT5032_Assignment {
public class RouteConfig {
public static void RegisterRoutes(RouteCollection routes) {
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
// Put Home folder into root route independently without keyword "Home"
routes.MapRoute(
name: "Home",
url: "{action}/{id}",
url: "{action}",
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

@ -0,0 +1,90 @@
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,8 +255,7 @@ namespace FIT5032_Assignment.Controllers {
});
db.SaveChanges();
} else {
db.Doctors.Add(new Doctors
{
db.Doctors.Add(new Doctors {
user = userUuid,
bio = "",
});

View File

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

View File

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

View File

@ -0,0 +1,40 @@
@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

@ -0,0 +1,11 @@

@{
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

@ -24,7 +24,7 @@
<p><b>Role</b> @ViewBag.role</p>
<hr />
<h2>Features</h2>
<p><a href="/MyImages">MyImages</a></p>
<p><a href="/Appointments/Index">Appointments</a></p>
<hr />
<p><button id="logoutbutton">Log out</button></p>