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 AddCourse() { var user = IdentityHelper.GetLmsUserForCurrentUser(this); var vm = new CourseInfoVM(); var response = _courseManager.GetGradeLevelsAndSubjects(); vm.TeacherId = user.UserId; vm.PopulateLists(response.Subjects, response.GradeLevels); vm.StartDate = DateTime.Today; vm.EndDate = DateTime.Today.AddMonths(6); return View(vm); }
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"); } }
public ActionResult Information(int id) { var response = _courseManager.GetCourseByIdAndSubjectsAndGradelevels(id); if (response.Success) { var vm = new CourseInfoVM(); vm.CourseDetails = response.CourseDetails; vm.PopulateCourseData(response.CourseDetails); vm.PopulateLists(response.Subjects, response.GradeLevels); return View(vm); } else { ViewBag.ErrorMsg = response.Message; return View("Error"); } }