public ActionResult DeleteTestView(string id) { if (!user.IsManager()) { return(View("Error")); } int id_Testcode = Convert.ToInt32(id); TestCandidateList checkTestCodeInTest = db.TestCandidateLists.FirstOrDefault(c => c.TestCode == id_Testcode); if (checkTestCodeInTest != null) { TempData["CandidateID"] = false; TempData["statusTV"] = "This test has a candidate"; return(RedirectToAction("TestView")); } bool del = managerDal.DeleteTestView(id_Testcode); if (del) { TempData["CandidateID"] = true; TempData["statusTV"] = "Delete successfull!"; } else { TempData["CandidateID"] = false; TempData["statusTV"] = "Delete failed!!"; } return(RedirectToAction("TestView")); }
public ActionResult DeleteCandidate(string id) { if (!user.IsManager()) { return(View("Error")); } int id_cand = Convert.ToInt32(id); TestCandidateList check = db.TestCandidateLists.FirstOrDefault(c => c.CandidateID == id_cand); if (check != null) { TempData["CandidateID"] = false; TempData["statusCAN"] = "This candidate has taken the test"; return(RedirectToAction("Candidate")); } bool del = managerDal.DeleteCandidate(id_cand); if (del) { TempData["CandidateID"] = true; TempData["statusCAN"] = "Delete successful"; } else { TempData["CandidateID"] = false; TempData["statusCAN"] = "Delete failed"; } return(RedirectToAction("Candidate")); }