Image read
This commit is contained in:
parent
ce5f7a5d8c
commit
30c3fbcadc
|
@ -28,6 +28,12 @@ namespace FIT5032_Assignment {
|
|||
url: "Appointments",
|
||||
defaults: new { controller = "Appointments", action = "Index", id = UrlParameter.Optional }
|
||||
);
|
||||
|
||||
routes.MapRoute(
|
||||
name: "System",
|
||||
url: "System/{action}/{id}",
|
||||
defaults: new { controller = "System", action = "GetUploadedImage", id = UrlParameter.Optional }
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -520,5 +520,53 @@ namespace FIT5032_Assignment.Controllers {
|
|||
return Redirect("/Appointments/Index");
|
||||
}
|
||||
}
|
||||
|
||||
public ActionResult Detail(string id) {
|
||||
// Verify login
|
||||
if (Request.Cookies["psg_auth_token"] == null) {
|
||||
// Redirect to home page
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
var user = psgCredentialVerify(Request.Cookies["psg_auth_token"].Value);
|
||||
if (user == null) {
|
||||
// Redirect to home page
|
||||
Response.Cookies["psg_auth_token"].Expires = DateTime.Now.AddDays(-1);
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
var userProfile = loginInfo(user);
|
||||
if (userProfile == null) {
|
||||
// Redirect to home page, and remove cookies
|
||||
Response.Cookies["psg_auth_token"].Expires = DateTime.Now.AddDays(-1);
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
|
||||
// Detect user role
|
||||
ViewBag.role = db.Users.Find(userProfile.uuid).role;
|
||||
|
||||
// Check if the appointment is belong to the doctor or patient
|
||||
var appointment = db.Appointments.Find(id);
|
||||
if (appointment == null) {
|
||||
TempData["tip"] = "The appointment does not exist.";
|
||||
return Redirect("/Appointments/Index");
|
||||
}
|
||||
if (appointment.patient != userProfile.uuid && appointment.responsibleBy != userProfile.uuid) {
|
||||
TempData["tip"] = "The appointment does not exist.";
|
||||
return Redirect("/Appointments/Index");
|
||||
}
|
||||
|
||||
ViewBag.appointment = appointment;
|
||||
|
||||
// Fetch doctor profile
|
||||
ViewBag.doctor = db.Doctors.Where(d => d.user == appointment.responsibleBy);
|
||||
ViewBag.doctorUser = db.Users.Find(appointment.responsibleBy);
|
||||
|
||||
// Fetch patient profile
|
||||
ViewBag.patient = db.Users.Find(appointment.patient);
|
||||
|
||||
// Fetch images
|
||||
var image = db.Images.Where(i => i.appointment == id).First();
|
||||
ViewBag.image = image;
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -412,6 +412,8 @@ namespace FIT5032_Assignment.Controllers {
|
|||
return new HttpStatusCodeResult(HttpStatusCode.BadGateway);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
21
FIT5032-Assignment/Controllers/System.cs
Normal file
21
FIT5032-Assignment/Controllers/System.cs
Normal file
|
@ -0,0 +1,21 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using System.IO;
|
||||
|
||||
namespace FIT5032_Assignment.Controllers {
|
||||
public class SystemController : Controller {
|
||||
// GET: System
|
||||
public ActionResult GetUploadedImage(string fileName) {
|
||||
var filePath = Server.MapPath("~/App_Data/upload_images/" + fileName);
|
||||
if (!System.IO.File.Exists(filePath)) {
|
||||
return HttpNotFound();
|
||||
}
|
||||
var fileContent = System.IO.File.ReadAllText(filePath);
|
||||
var contentType = MimeMapping.GetMimeMapping(fileName);
|
||||
return File(fileContent, contentType);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -186,6 +186,7 @@
|
|||
<Compile Include="App_Start\RouteConfig.cs" />
|
||||
<Compile Include="Controllers\AppointmentsController.cs" />
|
||||
<Compile Include="Controllers\HomeController.cs" />
|
||||
<Compile Include="Controllers\System.cs" />
|
||||
<Compile Include="Global.asax.cs">
|
||||
<DependentUpon>Global.asax</DependentUpon>
|
||||
</Compile>
|
||||
|
@ -323,10 +324,12 @@
|
|||
<Content Include="Views\Appointments\Index.cshtml" />
|
||||
<Content Include="Views\Appointments\Create.cshtml" />
|
||||
<Content Include="Views\Appointments\UploadImage.cshtml" />
|
||||
<Content Include="Views\Appointments\Detail.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="App_Data\upload_images\" />
|
||||
<Folder Include="Views\Default\" />
|
||||
<Folder Include="Views\System\" />
|
||||
<Folder Include="Views\Test\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<IISExpressUseClassicPipelineMode />
|
||||
<UseGlobalApplicationHostFile />
|
||||
<LastActiveSolutionConfig>Debug|Any CPU</LastActiveSolutionConfig>
|
||||
<Controller_SelectedScaffolderID>MvcControllerWithActionsScaffolder</Controller_SelectedScaffolderID>
|
||||
<Controller_SelectedScaffolderID>MvcControllerEmptyScaffolder</Controller_SelectedScaffolderID>
|
||||
<Controller_SelectedScaffolderCategoryPath>root/Common/MVC/Controller</Controller_SelectedScaffolderCategoryPath>
|
||||
<WebStackScaffolding_ControllerDialogWidth>600</WebStackScaffolding_ControllerDialogWidth>
|
||||
<WebStackScaffolding_LayoutPageFile>~/Views/Shared/_Layout.cshtml</WebStackScaffolding_LayoutPageFile>
|
||||
|
|
118
FIT5032-Assignment/Views/Appointments/Detail.cshtml
Normal file
118
FIT5032-Assignment/Views/Appointments/Detail.cshtml
Normal file
|
@ -0,0 +1,118 @@
|
|||
|
||||
@{
|
||||
ViewBag.Title = "Detail";
|
||||
Layout = "~/Views/Shared/_Layout.cshtml";
|
||||
}
|
||||
|
||||
<h2>Appointment detail</h2>
|
||||
|
||||
<div class="field">
|
||||
<div class="field-title">Appointment date</div>
|
||||
<div class="field-content field-content-user">@ViewBag.appointment.appointmentDate</div>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<div class="field-title">Doctor</div>
|
||||
<div class="field-content field-content-user">
|
||||
<img src="@ViewBag.doctorUser.avatar" />
|
||||
<span>@ViewBag.doctorUser.displayName</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<div class="field-title">Patient</div>
|
||||
<div class="field-content field-content-user">
|
||||
<img src="@ViewBag.patient.avatar" />
|
||||
<span>@ViewBag.patient.displayName</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<div class="field-title">Status</div>
|
||||
<div class="field-content">
|
||||
@if(ViewBag.appointment.status == 0) {
|
||||
<span class="badge badge-warning">Pending</span>
|
||||
} else if(ViewBag.appointment.status == 1) {
|
||||
<span class="badge badge-info">Waiting for serve</span>
|
||||
} else if(ViewBag.appointment.status == -1) {
|
||||
<span class="badge badge-secondary">Cancelled</span>
|
||||
} else if(ViewBag.appointment.status == 2) {
|
||||
<span class="badge badge-info">Completed</span>
|
||||
} else {
|
||||
<span class="badge badge-secondary">Unknown</span>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if(ViewBag.appointment.status == 2) {
|
||||
<div class="field">
|
||||
<div class="field-title">Attached image</div>
|
||||
<div class="field-content">
|
||||
<img src="/System/GetUploadedImage?fileName=@ViewBag.image.file" />
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@section Scripts {
|
||||
<style>
|
||||
.field {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.field .field-title {
|
||||
font-weight: bold;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
.field .field-content {
|
||||
padding-left: 10px;
|
||||
}
|
||||
.field .field-content-user {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.field .field-content-user img {
|
||||
width: 50px;
|
||||
border-radius: 50%;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.badge {
|
||||
border-radius: 0.25rem;
|
||||
border-width: 1px;
|
||||
}
|
||||
|
||||
.badge-warning {
|
||||
background-color: #ffc107;
|
||||
border-color: #ffc107;
|
||||
}
|
||||
|
||||
.badge-success {
|
||||
background-color: #28a745;
|
||||
border-color: #28a745;
|
||||
}
|
||||
|
||||
.badge-danger {
|
||||
background-color: #dc3545;
|
||||
border-color: #dc3545;
|
||||
}
|
||||
|
||||
.badge-info {
|
||||
background-color: #17a2b8;
|
||||
border-color: #17a2b8;
|
||||
}
|
||||
|
||||
.badge-secondary {
|
||||
background-color: #6c757d;
|
||||
border-color: #6c757d;
|
||||
}
|
||||
|
||||
.userprofile .displaname {
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.userprofile .avatar {
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
border-radius: 50%;
|
||||
}
|
||||
</style>
|
||||
}
|
|
@ -89,6 +89,8 @@
|
|||
<a href='./Cancel/@item.Item1.uuid' class="btn btn-sm btn-danger">Cancel</a>
|
||||
} else if (item.Item1.status == 1) {
|
||||
<a href="./UploadImage/@item.Item1.uuid" class="btn btn-sm btn-primary">Upload Image</a>
|
||||
} else if (item.Item1.status == 2) {
|
||||
<a href="./Detail/@item.Item1.uuid" class="btn btn-sm btn-primary">Detail</a>
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
|
|
Loading…
Reference in New Issue
Block a user