Esempio n. 1
0
        public void testDeleteQuestionByExamId()
        {
            QuestionModel model = new QuestionModel();
            Assert.IsTrue(model.deleteQuestionByExamId(13)>0);


        }
Esempio n. 2
0
 public ActionResult DeleteExam()
 {
     if (loginStatus() == false)
     {
         return Redirect("Login");
     }
     Dictionary<string,string> response = new Dictionary<string,string>();
     ExamModel examModel = new ExamModel();
     QuestionModel questionModel = new QuestionModel();
     int id;
     try
     {
         id = int.Parse(Request["id"]);
         if (Directory.Exists(Server.MapPath(string.Format("~/upload/{0}", id))))
         {
             Directory.Delete(Server.MapPath(string.Format("~/upload/{0}", id)),true);
         }
         int questionCol = questionModel.deleteQuestionByExamId(id);
         int examCol = examModel.deleteExam(id);
         if (questionCol > 0 && examCol > 0)
         {
             response.Add("status", "success");
         }
         else
         {
             response.Add("status", "failed");
             response.Add("error", "something wrong when delete the record from database!");
         }
     }
     catch 
     {
         response.Add("status", "failed");
         response.Add("error", "bad id!");
     }
     return Json(response);
 }