public ActionResult Save(ScheduleAdminView model) { if (!ModelState.IsValid) { return(View("Edit", model)); } try { if (model.Id == 0) { _scheduleServise.Add(model); } else { _scheduleServise.Update(model); } } catch (ItemAlreadyExistException) { ModelState.AddModelError("MovieId", "Item with this value already exists."); ModelState.AddModelError("SessionId", "Item with this value already exists."); ModelState.AddModelError("Date", "Item with this value already exists."); } return(View("Edit", model)); }
public ActionResult Edit(int id) { var model = new ScheduleAdminView(); if (id != 0) { model = _scheduleServise.GetItemForAdmin(id); } return(View(model)); }