public async Task <ActionResult> DeleteConfirmed(int id) { if (Session["role"] != null && Session["role"].ToString() == "ADM") { AvailableTest availableTest = await db.AvailableTests.FindAsync(id); db.AvailableTests.Remove(availableTest); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } else { return(View("~/Views/LabTestResults/NotLoggedIn.cshtml")); } }
public async Task <ActionResult> Edit([Bind(Include = "Id,TestName,CreatedDate")] AvailableTest availableTest) { if (Session["role"] != null && Session["role"].ToString() == "ADM") { if (ModelState.IsValid) { db.Entry(availableTest).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(availableTest)); } else { return(View("~/Views/LabTestResults/NotLoggedIn.cshtml")); } }
// GET: AvailableTests/Edit/5 public async Task <ActionResult> Edit(int?id) { if (Session["role"] != null && Session["role"].ToString() == "ADM") { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } AvailableTest availableTest = await db.AvailableTests.FindAsync(id); if (availableTest == null) { return(HttpNotFound()); } return(View(availableTest)); } else { return(View("~/Views/LabTestResults/NotLoggedIn.cshtml")); } }