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")); }