コード例 #1
0
        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"));
        }
コード例 #2
0
        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"));
        }