private void GetViewData(FirstStepReservationModel model) { var now = new AllFlightsForReservationsViewModel(); ProccessGoingFlights(model, now); //TODO if (ModelClass.OneWay == false) { ProccessReturning(model, now); } this.ViewData["AllFlightInfo"] = now; }
public IActionResult ProcessFirstStepReservationOnTop(FirstStepReservationModel model, bool oneWay) { if (ModelState.IsValid) { if (model.DepartureDate > model.ReturnDate) { ViewData["Error"] = "Arrival cannot be before Departure!"; return(View("ReservationsFlights", model)); } ModelClass.PassengersCount = model.People; ModelClass.SecondModel = model; GetViewData(model); return(View("ReservationsFlights", model)); } return(View("ReservationsFlights", model)); }
private void ProccessReturning(FirstStepReservationModel model, AllFlightsForReservationsViewModel now) { now.PagerOnReturning ??= new PagerViewModel(); now.PagerOnReturning.CurrentPage = now.PagerOnReturning.CurrentPage <= 0 ? 1 : now.PagerOnReturning.CurrentPage; List <FlightViewModel> items = context.Flights.Skip((now.PagerOnReturning.CurrentPage - 1) * PageSize).Take(PageSize).Select(c => new FlightViewModel() { Id = c.Id, From = c.From, To = c.To, Departure = c.Departure, Arrival = c.Arrival }).Where(c => c.From == model.To && c.To == model.From && c.Departure >= model.DepartureDate).ToList(); now.ReturningFlights = items; now.PagerOnReturning.PagesCount = (int)Math.Ceiling(context.Flights.Count() / (double)PageSize); }