View appointment detail

This commit is contained in:
Astrian Zheng 2023-10-19 14:43:55 +11:00
parent 30c3fbcadc
commit 7da2697088
3 changed files with 34 additions and 4 deletions

View File

@ -13,9 +13,18 @@ namespace FIT5032_Assignment.Controllers {
if (!System.IO.File.Exists(filePath)) { if (!System.IO.File.Exists(filePath)) {
return HttpNotFound(); return HttpNotFound();
} }
var fileContent = System.IO.File.ReadAllText(filePath); // Read binary data from the file
var contentType = MimeMapping.GetMimeMapping(fileName); byte[] fileBytes = System.IO.File.ReadAllBytes(filePath);
return File(fileContent, contentType);
// 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();
} }
} }
} }

View File

@ -48,10 +48,26 @@
<div class="field"> <div class="field">
<div class="field-title">Attached image</div> <div class="field-title">Attached image</div>
<div class="field-content"> <div class="field-content">
<img src="/System/GetUploadedImage?fileName=@ViewBag.image.file" /> <img class="field-content-image" src="/System/GetUploadedImage?fileName=@ViewBag.image.file" />
</div> </div>
</div> </div>
} }
<hr>
<h3>Operations</h3>
@if (ViewBag.appointment.status == 0) {
// Cancel
<a class="btn btn-light" href="../Cancel/@ViewBag.appointment.uuid">Cancel</a>
if (ViewBag.role == 2) {
// Approve
<a class="btn btn-light" href="../Approve/@ViewBag.appointment.uuid">Approve</a>
}
} else if (ViewBag.appointment.status == 1 && ViewBag.role == 2) {
<a href="../UploadImage/@ViewBag.appointment.uuid" class="btn btn-sm btn-primary">Upload Image</a>
} else if (ViewBag.appointment.status == 2 && ViewBag.role == 1) {
<a href="../Review/@ViewBag.appointment.uuid" class="btn btn-sm btn-primary">Rate your experience</a>
} else {
<i>No operation available</i>
}
@section Scripts { @section Scripts {
<style> <style>
@ -74,6 +90,9 @@
border-radius: 50%; border-radius: 50%;
margin-right: 10px; margin-right: 10px;
} }
.field .field-content img.field-content-image {
max-width: 60%;
}
.badge { .badge {
border-radius: 0.25rem; border-radius: 0.25rem;

View File

@ -48,6 +48,8 @@
<td> <td>
@if (item.Item1.status == 0) { @if (item.Item1.status == 0) {
<a href='./Cancel/@item.Item1.uuid' class="btn btn-sm btn-danger">Cancel</a> <a href='./Cancel/@item.Item1.uuid' class="btn btn-sm btn-danger">Cancel</a>
} else if (item.Item1.status == 2) {
<a href="./Detail/@item.Item1.uuid" class="btn btn-sm btn-primary">Detail</a>
} }
</td> </td>
</tr> </tr>