From 7da269708826af671990c06e75383ad397197b76 Mon Sep 17 00:00:00 2001 From: Astrian Zheng Date: Thu, 19 Oct 2023 14:43:55 +1100 Subject: [PATCH] View appointment detail --- FIT5032-Assignment/Controllers/System.cs | 15 ++++++++++--- .../Views/Appointments/Detail.cshtml | 21 ++++++++++++++++++- .../Views/Appointments/Index.cshtml | 2 ++ 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/FIT5032-Assignment/Controllers/System.cs b/FIT5032-Assignment/Controllers/System.cs index 5fc324b..b432e30 100644 --- a/FIT5032-Assignment/Controllers/System.cs +++ b/FIT5032-Assignment/Controllers/System.cs @@ -13,9 +13,18 @@ namespace FIT5032_Assignment.Controllers { if (!System.IO.File.Exists(filePath)) { return HttpNotFound(); } - var fileContent = System.IO.File.ReadAllText(filePath); - var contentType = MimeMapping.GetMimeMapping(fileName); - return File(fileContent, contentType); + // Read binary data from the file + byte[] fileBytes = System.IO.File.ReadAllBytes(filePath); + + // The binary file may png, jpg or jpeg + var fileExtension = Path.GetExtension(filePath).ToLowerInvariant(); + // Set the MIME type + if (fileExtension == ".png") { + return File(fileBytes, "image/png"); + } else if (fileExtension == ".jpg" || fileExtension == ".jpeg") { + return File(fileBytes, "image/jpeg"); + } + return HttpNotFound(); } } } \ No newline at end of file diff --git a/FIT5032-Assignment/Views/Appointments/Detail.cshtml b/FIT5032-Assignment/Views/Appointments/Detail.cshtml index b718131..65710a2 100644 --- a/FIT5032-Assignment/Views/Appointments/Detail.cshtml +++ b/FIT5032-Assignment/Views/Appointments/Detail.cshtml @@ -48,10 +48,26 @@
Attached image
- +
} +
+

Operations

+@if (ViewBag.appointment.status == 0) { + // Cancel + Cancel + if (ViewBag.role == 2) { + // Approve + Approve + } +} else if (ViewBag.appointment.status == 1 && ViewBag.role == 2) { + Upload Image +} else if (ViewBag.appointment.status == 2 && ViewBag.role == 1) { + Rate your experience +} else { + No operation available +} @section Scripts {