public IActionResult Index()
        {
            SightingSearchByAircraftViewModel model = new SightingSearchByAircraftViewModel
            {
                PageNumber = 1
            };

            return(View(model));
        }
        public async Task <IActionResult> Index(SightingSearchByAircraftViewModel model)
        {
            if (ModelState.IsValid)
            {
                int page = model.PageNumber;
                switch (model.Action)
                {
                case ControllerActions.ActionPreviousPage:
                    page -= 1;
                    break;

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

                case ControllerActions.ActionSearch:
                    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 <Sighting> sightings = null;

                try
                {
                    // Retrieve the aircraft with the specified registration number
                    // then, if we have a valid aircraft, retrieve its sightings
                    Aircraft aircraft = await _aircraft.GetAircraftByRegistrationAsync(model.Registration);

                    if (aircraft != null)
                    {
                        sightings = await _client.GetSightingsByAircraft(aircraft.Id, page, _settings.Value.SearchPageSize);
                    }
                }
                catch
                {
                }

                // Expose the sightings to the View
                model.SetSightings(sightings, page, _settings.Value.SearchPageSize);
            }

            return(View(model));
        }