Cancel appointments
This commit is contained in:
parent
80f8026d09
commit
9d483caa68
|
@ -132,11 +132,52 @@ namespace FIT5032_Assignment.Controllers {
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
// GET: Appointments/Details/5
|
// GET: Appointments/Cancel/uuid
|
||||||
public ActionResult Details(int id) {
|
public ActionResult Cancel(string id) {
|
||||||
return View();
|
// Check 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");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check status == 0
|
||||||
|
if (appointment.status != 0) {
|
||||||
|
TempData["tip"] = "Operation invalid";
|
||||||
|
return Redirect("/Appointments/Index");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update status
|
||||||
|
appointment.status = -1;
|
||||||
|
db.Entry(appointment).State = EntityState.Modified;
|
||||||
|
db.SaveChanges();
|
||||||
|
|
||||||
|
TempData["tip"] = "The appointment has been cancelled.";
|
||||||
|
return Redirect("/Appointments/Index");
|
||||||
|
}
|
||||||
|
|
||||||
public ActionResult Approve(string id) {
|
public ActionResult Approve(string id) {
|
||||||
// Check login
|
// Check login
|
||||||
if (Request.Cookies["psg_auth_token"] == null) {
|
if (Request.Cookies["psg_auth_token"] == null) {
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@if (item.Item1.status == 0) {
|
@if (item.Item1.status == 0) {
|
||||||
<button class="btn btn-sm btn-danger">Cancel</button>
|
<a href='./Cancel/@item.Item1.uuid' class="btn btn-sm btn-danger">Cancel</a>
|
||||||
}
|
}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -86,7 +86,9 @@
|
||||||
<td>
|
<td>
|
||||||
@if (item.Item1.status == 0) {
|
@if (item.Item1.status == 0) {
|
||||||
<a href='./Approve/@item.Item1.uuid' class="btn btn-sm btn-primary">Approve</a>
|
<a href='./Approve/@item.Item1.uuid' class="btn btn-sm btn-primary">Approve</a>
|
||||||
<button class="btn btn-sm btn-danger">Cancel</button>
|
<a href='./Cancel/@item.Item1.uuid' class="btn btn-sm btn-danger">Cancel</a>
|
||||||
|
} else if (item.Item1.status == 1) {
|
||||||
|
<a href="." class="btn btn-sm btn-primary">Upload Image</a>
|
||||||
}
|
}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user