public IActionResult OnAirportsGet()
        {
            var airportDataService = new AirportDataService(this._env);
            var data = airportDataService.GetAll();

            return(new JsonResult(data));
        }
        public AirportSearchViewModel()
        {
            filteredAirports = new ObservableCollection <Airport>(AirportDataService.ReadAll());

            SortResultsCommand = new MessageCommands(FilterAirportList);
            selectionMade      = new MapCommands(GatherFlightData);
            setMapLatLong      = new MapCommands(SetMapLatLong);
            addToFavorites     = new MapCommands(AddToFavorites);
            openHelp           = new MapCommands(OpenHelp);
            AirportCount       = "Airport Count = " + filteredAirports.Count().ToString();
            Center             = new PointLatLng(39.9, -84.4);
            MapZoom            = 4;
        }
        protected async Task HandleValidSubmit()
        {
            var response = await AirportDataService.AddAirport(Airport);

            if (response != null)
            {
                await BlazoredModal.Close();

                ToastService.ShowSuccess($"New Airport {response.ICAO} was created");
            }

            //await CloseEventCallback.InvokeAsync(true);
            StateHasChanged();
        }
        public void GetFilteredAirports(string searchBoxText)
        {
            //List<Airport> airports = new List<Airport>();
            //airports = AirportDataService.ReadAll();

            List <Airport> airports     = AirportDataService.ReadAll();
            List <Airport> filteredList = airports.Where(a => a.name.ToUpper().Contains(searchBoxText.ToUpper())).ToList();

            foreach (Airport item in filteredList)
            {
                filteredAirports.Add(item);
            }

            if (filteredAirports.Count == 0)
            {
                AirportCount = "Airport Count = " + filteredAirports.Count().ToString() + ". Try to broaden your search!";
            }
            else
            {
                AirportCount = "Airport Count = " + filteredAirports.Count().ToString();
            }
        }
示例#5
0
        public IActionResult Get()
        {
            var svc      = new AirportDataService(this._env);
            var features = svc.GetAll().Select(o => new
            {
                type     = "Feature",
                geometry = new
                {
                    type        = "Point",
                    coordinates = new[] { o.Longitude, o.Latitude }
                },
                properties = new
                {
                    name     = o.Name,
                    iataCode = o.IATA
                }
            });

            return(Ok(new {
                type = "FeatureCollection",
                features
            }));
        }
示例#6
0
 protected override async Task OnInitializedAsync()
 {
     Airport = await AirportDataService.GetAirportWithFlightsById(AirportId);
 }
        public void GatherFlightData()
        {
            if (selectedAirport != null)
            {
                //generate airport MasterList
                List <Airport> airportMasterList = AirportDataService.ReadAll();

                //generate view model to send results to
                ViewFlightDataViewModel vm = new ViewFlightDataViewModel();

                //generate url request parameters
                string departureAirport = "depIcao=" + selectedAirport.code;
                string arrivalAirport   = "arrIcao=" + selectedAirport.code;

                //load results in...
                List <FlightData> flightsArrivingToThisAirport = AviationEdgeAPIDataService.GetCurrentFlightData(arrivalAirport, out APIErrorCode arrivalFlightsError);
                //add second request
                List <FlightData> flightsLeavingThisAirport = AviationEdgeAPIDataService.GetCurrentFlightData(departureAirport, out APIErrorCode departureFlightsError);

                ////Test purpose
                //List<FlightData> test = AviationEdgeAPIDataService.ReadAll();


                if (arrivalFlightsError == APIErrorCode.VALIDFLIGHTDATA)
                {
                    foreach (FlightData item in flightsArrivingToThisAirport)
                    {
                        vm.flightDataRecords.Add(item);

                        GMapMarker marker = GenerateDestinationMarkers(item, airportMasterList, out MarkerErrorCode destinationMarkerErrorCode);
                        if (destinationMarkerErrorCode == MarkerErrorCode.VALID)
                        {
                            vm.flightsOnRouteToThisAirport.Add(marker);
                        }
                        else
                        {
                            errorList.Add("Destination marker missing for flight number: " + item.flight.number);
                        }
                        GMapMarker airplaneMarker = GenerateMapAirplaneMarkers(item, out MarkerErrorCode planeMarkerError);
                        if (planeMarkerError == MarkerErrorCode.VALID)
                        {
                            vm.flightsOnRouteToThisAirport.Add(airplaneMarker);
                        }
                        else
                        {
                            errorList.Add("Airplane marker missing for flight number: " + item.flight.number);
                        }
                        GMapPolygon gMapPolygon = GenerateMapRoutesFromDep(item, airportMasterList, out MarkerErrorCode errorCode);
                        if (errorCode == MarkerErrorCode.VALID)
                        {
                            vm.flightsOnRouteToThisAirport.Add(gMapPolygon);
                        }
                        else
                        {
                            errorList.Add("Partial map route missing for flight number: " + item.flight.number);
                        }
                        GMapPolygon routeFromFlightToArrv = GenerateMapRoutesFromCurrentToArv(item, airportMasterList, out MarkerErrorCode routeToError);
                        if (routeToError == MarkerErrorCode.VALID)
                        {
                            vm.flightsOnRouteToThisAirport.Add(routeFromFlightToArrv);
                        }
                        else
                        {
                            errorList.Add("Partial map route missing for flight number: " + item.flight.number);
                        }
                    }
                }
                if (departureFlightsError == APIErrorCode.VALIDFLIGHTDATA)
                {
                    foreach (FlightData item in flightsLeavingThisAirport)
                    {
                        vm.flightDataRecords.Add(item);
                        GMapMarker destinationMarker = GenerateDestinationMarkers(item, airportMasterList, out MarkerErrorCode destinationMarkerError);
                        if (destinationMarkerError == MarkerErrorCode.VALID)
                        {
                            vm.mapMarkers.Add(destinationMarker);
                        }
                        else
                        {
                            errorList.Add("Destination marker missing for flight number: " + item.flight.number);
                        }
                        GMapMarker airplaneIcon = GenerateMapAirplaneMarkers(item, out MarkerErrorCode airplaneIconError);
                        if (airplaneIconError == MarkerErrorCode.VALID)
                        {
                            vm.mapMarkers.Add(airplaneIcon);
                        }
                        else
                        {
                            errorList.Add("Airplane marker missing for flight number: " + item.flight.number);
                        }
                        GMapPolygon fromDep = GenerateMapRoutesFromDep(item, airportMasterList, out MarkerErrorCode routeFromDepError);
                        if (routeFromDepError == MarkerErrorCode.VALID)
                        {
                            vm.mapMarkers.Add(fromDep);
                        }
                        else
                        {
                            errorList.Add("Partial map route missing for flight number: " + item.flight.number);
                        }
                        GMapPolygon toArriv = GenerateMapRoutesFromCurrentToArv(item, airportMasterList, out MarkerErrorCode routeToArrvError);
                        if (routeToArrvError == MarkerErrorCode.VALID)
                        {
                            vm.mapMarkers.Add(toArriv);
                        }
                        else
                        {
                            errorList.Add("Partial map route missing for flight number: " + item.flight.number);
                        }
                    }
                }
                if (arrivalFlightsError == APIErrorCode.INVALIDFLIGHTDATA && departureFlightsError == APIErrorCode.INVALIDFLIGHTDATA)
                {
                    MessageBox.Show($"There are no flights found arriving or departing {selectedAirport.name}");
                }
                else
                {
                    vm.airport     = selectedAirport;
                    vm.RecordCount = "Flight Count= " + vm.flightDataRecords.Count.ToString();
                    foreach (string error in errorList)
                    {
                        vm.errors.Add(error);
                    }
                    vm.ErrorLabel = $"Errors({errorList.Count()})";
                    vm.Center     = new PointLatLng(double.Parse(selectedAirport.lat), double.Parse(selectedAirport.lon));
                    ViewFlightData viewFlightDataUI = new ViewFlightData(vm);
                    viewFlightDataUI.Show();
                    errorList.Clear();
                }
            }
            else
            {
                //If no airport has been selected...
                MessageBox.Show("No Airport Selection Has Been Made! Please select an airport or click 'Help' for more information.");
            }
        }
        public List <Airport> GetAirports()
        {
            List <Airport> airports = new List <Airport>();

            return(airports = AirportDataService.ReadAll());
        }