public ActionResult ChooseSeats(int?id) { if (!id.HasValue) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var flight = flightRepository.GetFullFlightWithSeats(id ?? (int)InvalidPropertyValues.undefinedValue); if (flight == null) { return(HttpNotFound()); } var viewModel = new FullFlightViewModel(flight); return(View(viewModel)); }
public ActionResult CheckSeatAvailability(int?FlightId, long[] flightSeatIds) { if (!FlightId.HasValue) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var flight = flightRepository.GetFullFlightWithSeats(FlightId ?? (int)InvalidPropertyValues.undefinedValue); if (flight == null) { return(HttpNotFound()); } if (flightSeatIds == null) { var viewModel = new FullFlightViewModel(flight); ModelState.AddModelError("MinimunSeats", "You must choose at least one seat."); return(View("ChooseSeats", viewModel)); } var flightSeats = flightSeatRepository.GetAvailableFlightSeatsById(flightSeatIds); if (flightSeats.Count != flightSeatIds.Length) { var viewModel = new FullFlightViewModel(flight); ModelState.AddModelError("UnavailableSeats", "One or more of the seats you choose are unavailable."); return(View("ChooseSeats", viewModel)); } Session["flight"] = flight; Session["flightSeats"] = flightSeats; //The refresh interval is used for preventing the user refresh the order page TempData["RefreshInterval"] = -1; return(RedirectToAction("Create", "Order")); }