Beispiel #1
0
        public async Task <IActionResult> PassengerDetails(string id)
        {
            List <Reservation> passengers = context.Reservations.Where(r => r.FlightId == id).ToList();

            FlightsPassengerViewModel model = new FlightsPassengerViewModel()
            {
                Passengers = passengers
            };



            return(RedirectToAction("Index", "Reservation", model, id));
        }
Beispiel #2
0
        public async Task <IActionResult> Index(string id, FlightsPassengerViewModel model)
        {
            model.Pager ??= new PagerViewModel();
            model.Pager.CurrentPage = model.Pager.CurrentPage <= 0 ? 1 : model.Pager.CurrentPage;

            int passengersCount = await this.context.Reservations.Where(x => x.FlightId == id).CountAsync();

            List <Reservation> passengers = await context.Reservations.Where(x => x.FlightId == id).Skip((model.Pager.CurrentPage - 1) * PAGE_SIZE).Take(PAGE_SIZE).ToListAsync();

            model.Passengers       = passengers;
            model.Pager.PagesCount = (int)Math.Ceiling(await context.Reservations.CountAsync() / (double)PAGE_SIZE);

            if (model.Pager.PagesCount > passengersCount)
            {
                model.Pager.PagesCount = passengersCount;
            }

            return(View("ReservationView", model));
        }