public IActionResult Insert([FromBody] Exam exam)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            return(Ok(_service.AddExam(exam)));
        }
Exemple #2
0
 public IActionResult ExamCreated(Exam exam)
 {
     if (!ModelState.IsValid)
     {
         ModelState.AddModelError(string.Empty, "Something went wrong");
         return(View("CreateExam"));
     }
     _examService.AddExam(exam);
     return(View());
 }
Exemple #3
0
        public IActionResult AddExam([FromBody] ExamStorage exam)
        {
            string account = HttpContext.Session.GetString("admin");

            if (exam.Code != "")
            {
                exam.Group = "验证码";
            }
            exam.Publisher   = admin.GetByAccount(account).name;
            exam.PublishTime = DateTime.Now.ToString("yyyy-MM-dd");
            Exam.AddExam(exam);
            return(Content("1"));
        }
Exemple #4
0
 public ActionResult Create(Exam exam)
 {
     try
     {
         if (examService.AddExam(exam) > 0)
         {
             Success = "Insert Exam successfully!";
             return(RedirectToAction("Index", "Exams"));
         }
         else
         {
             Failure = "Something went wrong, please try again!";
             return(RedirectToAction("Create", "Exams"));
         }
     }
     catch (Exception e)
     {
         Failure = "Something went wrong, please try again!";
         return(RedirectToAction("Create", "Exams"));
     }
 }
Exemple #5
0
 public async Task <IActionResult> Post(ExamViewModel exam)
 {
     return(Ok(await examService.AddExam(exam)));
 }