public ActionResult Edit(Models.ShowTimeFilm showTimeFilm) { if (ModelState.IsValid) { var dbShowTimeFilm = new Domain.ShowTimeFilm(); dbShowTimeFilm.InjectFrom(showTimeFilm); showTimeFilmRepository.Update(dbShowTimeFilm); TempData["message"] = string.Format("{0} has been saved", showTimeFilm.ShowTime); unitOfWork.Commit(); } else { return(View(showTimeFilm)); } return(RedirectToAction("Index")); }
public ActionResult Create(Models.ShowTimeFilm model) { if (ModelState.IsValid) { if (!showTimeFilmService.ExistsStf(model.ShowTime)) { var dbModel = new Domain.ShowTimeFilm(); dbModel.InjectFrom(model); showTimeFilmService.AddShowTimeFilm(dbModel); TempData["message"] = string.Format("{0} has been saved", model.ShowTime); } else { ModelState.AddModelError("ShowTime", "Cant add a show time at the same hour in the same cinema!"); return(View(model)); } return(RedirectToAction("Index")); } return(View(model)); }