public ActionResult AddCourse(CourseInfoVM vm) { if (vm.EndDate <= vm.StartDate) { ModelState.AddModelError("InvalidTimespan", "End date must be after start date."); } if (!ModelState.IsValid) { var response = _courseManager.GetGradeLevelsAndSubjects(); if (response.Success) { vm.PopulateLists(response.Subjects, response.GradeLevels); return View(vm); } else { ViewBag.ErrorMsg = response.Message; return View("Error"); } } var updateResponse = _courseManager.AddCourse(vm.GetCourseFromVM()); if (updateResponse.Success) { return RedirectToAction("Index", "Teachers"); } else { ViewBag.ErrorMsg = updateResponse.Message; return View("Error"); } }
public ActionResult Information(CourseInfoVM vm) { if (vm.EndDate <= vm.StartDate) { ModelState.AddModelError("InvalidTimespan", "End date must be after start date."); } if (!ModelState.IsValid) { var response = _courseManager.GetCourseByIdAndSubjectsAndGradelevels(vm.CourseId); if (response.Success) { vm.CourseDetails = response.CourseDetails; vm.PopulateLists(response.Subjects, response.GradeLevels); return View(vm); } else { ViewBag.ErrorMsg = response.Message; return View("Error"); } } var updateResponse = _courseManager.UpdateCourseInfo(vm.GetCourseFromVM()); if (updateResponse.Success) { return RedirectToAction("Information", new { id = vm.CourseId }); } else { ViewBag.ErrorMsg = updateResponse.Message; return View("Error"); } }