public ActionResult EditCourse(int id, EditCourseViewModel model) { if (!ModelState.IsValid) { return(View(model)); } var course = CourseServiceCaller.Get(id); if (!String.IsNullOrEmpty(model.CourseName)) { course.Name = model.CourseName; } if (!String.IsNullOrEmpty(model.CourseProfessor)) { course.Professor = model.CourseProfessor; } if (!String.IsNullOrEmpty(model.CourseHour.ToString())) { course.Hour = model.CourseHour ?? 0; } if (!model.CourseDay.Equals("Default")) { course.Day = GetWeekDayFromString(model.CourseDay); } try { CourseServiceCaller.Update(course); return(RedirectToAction("Index", "Course")); } catch (Exception ex) { return(View(ex.Message)); } }
public ActionResult EditCourse(int id) { ViewBag.CourseId = id; var course = CourseServiceCaller.Get(id); var courseModel = new EditCourseViewModel() { CourseDay = course.Day.ToString(), CourseHour = course.Hour, CourseName = course.Name, CourseProfessor = course.Professor }; return(View(courseModel)); }
public ActionResult Delete(int id) { CourseServiceCaller.Delete(id); return(RedirectToAction("Index")); }