public async Task<ActionResult> CreateHall(Hall hall) { if (ModelState.IsValid) { Cinema cinema = await db.Cinemas.FindAsync(c => c.Id == hall.CinemaId); hall.Cinema = cinema; await db.Halls.InsertAsync(hall); TempData["message"] = string.Format("Hall {0} has been saved", hall.Name); return RedirectToAction("ViewHalls", new { cinemaId = hall.CinemaId }); } else { TempData["message"] = string.Format("Hall hasn't been saved"); return View(hall); } }
public async Task<ActionResult> EditHall(Hall hall) { if (ModelState.IsValid) { await db.Halls.EditAsync(hall, hall.Id); TempData["message"] = string.Format("Hall {0} has been saved", hall.Name); return RedirectToAction("ViewHalls", new { cinemaId = hall.CinemaId }); } else { TempData["message"] = string.Format("Cinema hasn't been saved"); return View(hall); } }
public async Task<ActionResult> CreateHall(int? cinemaId) { if (cinemaId == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } Cinema cinema = await db.Cinemas.FindAsync(c => c.Id == cinemaId); if (cinema == null) { return HttpNotFound(); } ViewBag.CinemaId = cinemaId; Hall hall = new Hall(); hall.Cinema = cinema; hall.CinemaId = cinema.Id; return View(hall); }