diff --git a/FIT5032-Assignment/App_Start/RouteConfig.cs b/FIT5032-Assignment/App_Start/RouteConfig.cs index 6dda0cf..048910e 100644 --- a/FIT5032-Assignment/App_Start/RouteConfig.cs +++ b/FIT5032-Assignment/App_Start/RouteConfig.cs @@ -5,20 +5,23 @@ using System.Web; using System.Web.Mvc; using System.Web.Routing; -namespace FIT5032_Assignment -{ - public class RouteConfig - { - public static void RegisterRoutes(RouteCollection routes) - { - routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); +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}", - defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } - ); - } + // Put Home folder into root route independently without keyword "Home" + routes.MapRoute( + name: "Home", + 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 } + ); } + } } diff --git a/FIT5032-Assignment/Controllers/AppointmentsController.cs b/FIT5032-Assignment/Controllers/AppointmentsController.cs new file mode 100644 index 0000000..8fcab73 --- /dev/null +++ b/FIT5032-Assignment/Controllers/AppointmentsController.cs @@ -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 = db.Doctors.ToList(); + // Create a tuple for put uuid and displayName into it + List> doctorsList = new List>(); + List 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 doctor = new Tuple(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(); + } + } + } +} diff --git a/FIT5032-Assignment/Controllers/HomeController.cs b/FIT5032-Assignment/Controllers/HomeController.cs index 139c0aa..2def4ef 100644 --- a/FIT5032-Assignment/Controllers/HomeController.cs +++ b/FIT5032-Assignment/Controllers/HomeController.cs @@ -255,8 +255,7 @@ namespace FIT5032_Assignment.Controllers { }); db.SaveChanges(); } else { - db.Doctors.Add(new Doctors - { + db.Doctors.Add(new Doctors { user = userUuid, bio = "", }); diff --git a/FIT5032-Assignment/FIT5032-Assignment.csproj b/FIT5032-Assignment/FIT5032-Assignment.csproj index 4b3897b..95ccd9c 100644 --- a/FIT5032-Assignment/FIT5032-Assignment.csproj +++ b/FIT5032-Assignment/FIT5032-Assignment.csproj @@ -184,6 +184,7 @@ + Global.asax @@ -315,8 +316,11 @@ + + + diff --git a/FIT5032-Assignment/FIT5032-Assignment.csproj.user b/FIT5032-Assignment/FIT5032-Assignment.csproj.user index ed08c2e..186cd61 100644 --- a/FIT5032-Assignment/FIT5032-Assignment.csproj.user +++ b/FIT5032-Assignment/FIT5032-Assignment.csproj.user @@ -9,7 +9,7 @@ Debug|Any CPU - MvcControllerWithContextScaffolder + MvcControllerWithActionsScaffolder root/Common/MVC/Controller 600 ~/Views/Shared/_Layout.cshtml @@ -22,6 +22,8 @@ MvcViewScaffolder root/Common/MVC/View 600 + <_SelectedScaffolderID>MvcControllerEmptyScaffolder + <_SelectedScaffolderCategoryPath>root/Common diff --git a/FIT5032-Assignment/Views/Appointments/Create.cshtml b/FIT5032-Assignment/Views/Appointments/Create.cshtml new file mode 100644 index 0000000..25e2d10 --- /dev/null +++ b/FIT5032-Assignment/Views/Appointments/Create.cshtml @@ -0,0 +1,40 @@ +@model FIT5032_Assignment.Models.Appointments + +@{ + ViewBag.Title = "Create"; + Layout = "~/Views/Shared/_Layout.cshtml"; +} + +

Create

+ + +@using (Html.BeginForm()) { + @Html.AntiForgeryToken() + +
+

Appointments

+
+ +
+ @Html.LabelFor(model => model.responsibleBy, "Select a doctor", htmlAttributes: new { @class = "control-label col-md-2" }) +
+ @Html.DropDownList("user.displayName", @ViewBag.doctorsList as SelectList, htmlAttributes: new { @class = "form-control" }) + @Html.ValidationMessageFor(model => model.responsibleBy, "", new { @class = "text-danger" }) +
+
+ +
+
+ +
+
+
+} + +
+ @Html.ActionLink("Back to List", "Index") +
+ +@section Scripts { + @Scripts.Render("~/bundles/jqueryval") +} diff --git a/FIT5032-Assignment/Views/Appointments/Index.cshtml b/FIT5032-Assignment/Views/Appointments/Index.cshtml new file mode 100644 index 0000000..62e0a06 --- /dev/null +++ b/FIT5032-Assignment/Views/Appointments/Index.cshtml @@ -0,0 +1,11 @@ + +@{ + ViewBag.Title = "Appointments"; + Layout = "~/Views/Shared/_Layout.cshtml"; +} + +

Appointments

+ + \ No newline at end of file diff --git a/FIT5032-Assignment/Views/Home/Index.cshtml b/FIT5032-Assignment/Views/Home/Index.cshtml index 6967d16..a3ddc9e 100644 --- a/FIT5032-Assignment/Views/Home/Index.cshtml +++ b/FIT5032-Assignment/Views/Home/Index.cshtml @@ -24,7 +24,7 @@

Role @ViewBag.role


Features

-

MyImages

+

Appointments