public ActionResult SaveEdit(Screening screening) { if (!ModelState.IsValid) { var viewModel = new ScreeningFormViewModel { Screening = screening, Halls = _context.Halls.ToList(), Movie = _context.Movies.ToList() }; return(View("ScreeningForm", viewModel)); } if (_context.Screenings.Find(screening.Date, screening.HallId) != null) { return(View("Error")); } var oldScreenInDb = _context.Screenings.Find(Session["date"], Session["hallId"]); _context.Screenings.Remove(oldScreenInDb); _context.Screenings.Add(screening); _context.SaveChanges(); return(RedirectToAction("Index", "Home")); }
public ViewResult New() { var halls = _context.Halls.ToList(); var movies = _context.Movies.ToList(); var viewModel = new ScreeningFormViewModel { Movie = movies, Halls = halls, Screening = new Screening() }; return(View("ScreeningForm", viewModel)); }
public ActionResult Edit(DateTime?date, byte hallId) { var screen = _context.Screenings.Find(date, hallId); if (screen == null) { return(HttpNotFound()); } var viewModel = new ScreeningFormViewModel { Movie = _context.Movies.ToList(), Halls = _context.Halls.ToList(), Screening = screen }; Session["date"] = date; Session["hallId"] = hallId; return(View("ScreeningFormEdit", viewModel)); }