public IActionResult Insert([FromBody] Exam exam) { if (!ModelState.IsValid) { return(BadRequest()); } return(Ok(_service.AddExam(exam))); }
public IActionResult ExamCreated(Exam exam) { if (!ModelState.IsValid) { ModelState.AddModelError(string.Empty, "Something went wrong"); return(View("CreateExam")); } _examService.AddExam(exam); return(View()); }
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")); }
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")); } }
public async Task <IActionResult> Post(ExamViewModel exam) { return(Ok(await examService.AddExam(exam))); }