Ejemplo n.º 1
0
        public async Task <IActionResult> Index(AllFlightsViewModel model)
        {
            int page = model.PageNumber;

            switch (model.Action)
            {
            case ControllerActions.ActionPreviousPage:
                page -= 1;
                break;

            case ControllerActions.ActionNextPage:
                page += 1;
                break;

            default:
                break;
            }

            // Need to clear model state here or the page number that was posted
            // is returned and page navigation doesn't work correctly. So, capture
            // and amend the page number, above, then apply it, below
            ModelState.Clear();

            List <Flight> flights = await _client.GetFlightsAsync(page, _settings.Value.FlightSearchPageSize);

            model.SetFlights(flights, page, _settings.Value.FlightSearchPageSize);
            return(View(model));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Index()
        {
            AllFlightsViewModel model   = new AllFlightsViewModel();
            List <Flight>       flights = await _client.GetFlightsAsync(1, _settings.Value.FlightSearchPageSize);

            model.SetFlights(flights, 1, _settings.Value.FlightSearchPageSize);
            return(View(model));
        }