private double ValidateAirportDistanceResult(AirportModel firstAirportModel, AirportModel secondAirportModel)
        {
            var distance = 0.0;

            if (firstAirportModel.Lat != 0 &&
                firstAirportModel.Lon != 0 &&
                secondAirportModel.Lat != 0 &&
                secondAirportModel.Lon != 0)
            {
                distance = DistanceCalculator.GetDistanceFromLatLonInMl(firstAirportModel.Lat, firstAirportModel.Lon, secondAirportModel.Lat, secondAirportModel.Lon);
                return(distance);
            }
            return(distance);
        }
Ejemplo n.º 2
0
        public ActionResult AddNewAirport(FormCollection collection)
        {
            var airport = new AirportModel
            {
                Name      = collection.Get("name"),
                City      = collection.Get("city"),
                CountryID = int.Parse(collection.Get("countryid"))
            };

            this.AirportService.Insert(airport);
            TempData["msg"] = "success-Country add successfully";

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 3
0
        public void FindFlightCheck()
        {
            AirportModel air_test1 = new AirportModel
            {
                direction     = "Japan",
                departureTime = new DateTime(2008, 3, 1, 7, 0, 0),
                arriveTime    = new DateTime(2008, 3, 1, 10, 0, 0),
            };

            m.FlightAddition(air_test1);
            foreach (Airport air in m.GetList())
            {
                Assert.Contains(air, m.GetList());
            }
        }
Ejemplo n.º 4
0
        public AirportModel GetById(Guid?id)
        {
            AirportModel result = null;

            if (id.HasValue)
            {
                Airport airport = this.airportRepo.GetById(id.Value);
                if (airport != null)
                {
                    result = new AirportModel(airport);
                }
            }

            return(result);
        }
Ejemplo n.º 5
0
        public void selectByTimeCheck()
        {
            AirportModel airportModel = new AirportModel
            {
                direction     = "Japan",
                departureTime = new DateTime(2008, 3, 1, 4, 0, 0),
                arriveTime    = new DateTime(2008, 3, 1, 5, 0, 0),
            };

            m.FlightAddition(airportModel);
            foreach (Airport air in m.selectByTime())
            {
                Assert.Contains(air, m.selectByTime());
            }
        }
Ejemplo n.º 6
0
 private AirlineFboDbModel GetCalcAirlineFbo(AirportModel airport, int countFbosInDB)
 {
     return(new AirlineFboDbModel()
     {
         Name = airport.Name,
         Elevation = airport.Elevation,
         RunwaySize = airport.RunwaySize,
         Icao = airport.ICAO,
         Availability = 15 - countFbosInDB,
         FuelPriceDiscount = Math.Round(airport.RunwaySize / (double)62423, 2),
         GroundCrewDiscount = Math.Round(airport.RunwaySize / (double)41093, 2),
         ScoreIncrease = airport.RunwaySize / 1123,
         Price = (airport.RunwaySize * 78)
     });
 }
Ejemplo n.º 7
0
        public async Task <AirportModel> AddAirport(AirportModel airport)
        {
            _httpClient.SetBearerToken(await _tokenManager.RetrieveAccessTokenAsync());

            var employeeJson =
                new StringContent(JsonSerializer.Serialize(airport), Encoding.UTF8, "application/json");

            var response = await _httpClient.PostAsync("api/airports", employeeJson);

            if (response.IsSuccessStatusCode)
            {
                return(await JsonSerializer.DeserializeAsync <AirportModel>(await response.Content.ReadAsStreamAsync()));
            }

            return(null);
        }
        private void ListView_ItemTapped(object sender, ItemTappedEventArgs e)
        {
            var item = (e.Item as AirportInfoModel);

            if (item != null)
            {
                var model = new AirportModel
                {
                    OriginIata  = ViewModel.Iata,
                    Date        = ViewModel.DateTime.ToString("yyyy-MM-dd"),
                    DestinyIata = item.Iata,
                    Name        = item.Name
                };
                ViewModel.NavigationService.Navigate <DetailsViewModel, AirportModel>(model);
            }
        }
Ejemplo n.º 9
0
        public void selectByDirectionCheck()
        {
            AirportModel airportModel = new AirportModel
            {
                direction     = "Japan",
                departureTime = new DateTime(2008, 3, 1, 7, 0, 0),
                arriveTime    = new DateTime(2008, 3, 1, 10, 0, 0),
            };

            m.FlightAddition(airportModel);

            foreach (Airport air in m.selectByDirection("Japan"))
            {
                Assert.AreEqual(airportModel.direction, air.direction);
            }
        }
Ejemplo n.º 10
0
        public async Task Post([FromBody] AirportModel airport)
        {
            using (var connection = GetOpenConnection())
            {
                string query = "INSERT INTO Airports (AirportName, AirportCode, CityName, CountryName, Latitude, Longitude) " +
                               "VALUES(@AirportName, @AirportCode, @CityName, @CountryName, @Latitude, @Longitude)";
                SqlCommand cmd = new SqlCommand(query, (SqlConnection)connection);

                cmd.Parameters.AddWithValue("@AirportName", airport.AirportName);
                cmd.Parameters.AddWithValue("@AirportCode", airport.AirportCode);
                cmd.Parameters.AddWithValue("@CityName", airport.CityName);
                cmd.Parameters.AddWithValue("@CountryName", airport.CountryName);
                cmd.Parameters.AddWithValue("@Latitude", airport.Latitude);
                cmd.Parameters.AddWithValue("@Longitude", airport.Longitude);
                cmd.ExecuteNonQuery();
            }
        }
Ejemplo n.º 11
0
        public void ReturnModels_WhenPassetParametersAreCorrect()
        {
            // Arrange
            var airportServiceMock = new Mock <IAirportService>();

            var collection = new List <AirportModel>();


            for (int i = 0; i < 2; i++)
            {
                var airportModel = new AirportModel()
                {
                    Id               = Guid.NewGuid(),
                    Name             = "Sofia" + i,
                    AirportCode      = "LBSF" + i,
                    DepartureFlights = new List <FlightModel>()
                    {
                        new FlightModel()
                        {
                            Id = Guid.NewGuid(), Title = "FD123", Price = 100, Duration = TimeSpan.Parse("02:10:00")
                        }
                    },
                    ArrivalFlights = new List <FlightModel>()
                    {
                        new FlightModel()
                        {
                            Id = Guid.NewGuid(), Title = "FD987", Price = 150, Duration = TimeSpan.Parse("02:00:00")
                        }
                    }
                };
                collection.Add(airportModel);
            }

            var collectionAirportViewtModels = new List <AirportViewModel>();

            airportServiceMock.Setup(x => x.GetAllAirportsSortedByName()).Returns(collection);

            var homeController = new HomeController(airportServiceMock.Object);

            // Act
            var result = homeController.AllAirports();

            // Assert
            Assert.IsNotNull(result);
        }
 public ActionResult UpdateAirport(String id)
 {
     if (Session["role"] != null)
     {
         if ((string)Session["role"] == "admin")
         {
             Repository   r     = new Repository();
             Airport      a     = r.GetAirport(id);
             AirportModel model = new AirportModel();
             model.AirportCode = a.AirportCode;
             model.AirportName = a.AirportName;
             model.Description = a.Description;
             model.Location    = a.Location;
             return(View(model));
         }
     }
     return(RedirectToAction("Login", "User"));
 }
Ejemplo n.º 13
0
        public async Task PostEdit([FromBody] AirportModel airport)
        {
            using (var connection = GetOpenConnection())
            {
                string query = "UPDATE Airports " +
                               "SET AirportName = @AirportName, AirportCode = @AirportCode, CityName = @CityName, CountryName = @CountryName, Latitude = @Latitude, Longitude = @Longitude " +
                               "WHERE AirportId = @AirportId";
                SqlCommand cmd = new SqlCommand(query, (SqlConnection)connection);

                cmd.Parameters.AddWithValue("@AirportId", airport.AirportId);
                cmd.Parameters.AddWithValue("@AirportName", airport.AirportName);
                cmd.Parameters.AddWithValue("@AirportCode", airport.AirportCode);
                cmd.Parameters.AddWithValue("@CityName", airport.CityName);
                cmd.Parameters.AddWithValue("@CountryName", airport.CountryName);
                cmd.Parameters.AddWithValue("@Latitude", airport.Latitude);
                cmd.Parameters.AddWithValue("@Longitude", airport.Longitude);
                cmd.ExecuteNonQuery();
            }
        }
Ejemplo n.º 14
0
        public OpenWeatherModel Get(int airportId)
        {
            AirportModel airport = new AirportModel();

            using (var connection = GetOpenConnection())
            {
                airport = connection.Query <AirportModel>(
                    @"select AirportId, AirportName, CityName, CountryName, AirportCode, Latitude, Longitude
                        from Airports where AirportId = " + airportId).FirstOrDefault();//<= TODO: use parameters
            }
            //TODO: add link to config
            string urlBase = "http://api.openweathermap.org/data/2.5/onecall?lat={0}&lon={1}&exclude=minutely,hourly,daily&APPID=6ce31626181846df8fb15eed32a345b0&units=metric";
            string url     = String.Format(urlBase, airport.Latitude, airport.Longitude);
            OpenWeatherViewModel weatherForecastViewModel = new OpenWeatherViewModel();
            string         answer;
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

            request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;

            using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
                using (Stream stream = response.GetResponseStream())
                    using (StreamReader reader = new StreamReader(stream))
                    {
                        answer = reader.ReadToEnd();
                    }

            weatherForecastViewModel = JsonConvert.DeserializeObject <OpenWeatherViewModel>(answer);

            OpenWeatherModel model = new OpenWeatherModel();

            model = new OpenWeatherModel
            {
                CountryName            = airport.AirportName,//TODO: change property to airpirtName
                Sunrise                = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc).AddSeconds(weatherForecastViewModel.Current.Sunrise).ToLocalTime(),
                Sunset                 = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc).AddSeconds(weatherForecastViewModel.Current.Sunset).ToLocalTime(),
                Temperature            = weatherForecastViewModel.Current.Temp,
                WeatherMainDescription = weatherForecastViewModel.Current.Weather.Select(w => w.Main).Aggregate((i, j) => i + " " + j),
                Updated                = DateTime.Now,
                Icon = "http://openweathermap.org/img/wn/" + weatherForecastViewModel.Current.Weather.First()?.Icon + "@2x.png"
            };

            return(model);
        }
Ejemplo n.º 15
0
        public override Task <DefaultResponse> AddAirport(AirportModel request, ServerCallContext context)
        {
            try
            {
                var airport = new AirportRaw()
                {
                    City    = request.City,
                    Country = request.Country,
                    Name    = request.Name
                };
                _airportRepository.AddAirport(airport);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, $"ERROR: Add {request.Name} Airport");
            }

            return(Task.FromResult(new DefaultResponse()));
        }
Ejemplo n.º 16
0
        public List <RouteModel> ShortestRoute(string origin, string destination)
        {
            if (!airports.Any(a => a.IATA3 == origin))
            {
                throw new OriginNotFoundException();
            }
            if (!airports.Any(a => a.IATA3 == destination))
            {
                throw new DestinationNotFoundException();
            }

            AirportModel airportOrigin      = airports.FirstOrDefault(a => a.IATA3 == origin);
            AirportModel airportDestination = airports.FirstOrDefault(a => a.IATA3 == destination);

            var shortestPath            = this.ShortestPathFunction(_graphNetwork, airportOrigin);
            var AirportsPath            = shortestPath(airportDestination);
            List <RouteModel> finalPath = this.SetAirlines(AirportsPath);

            return(finalPath);
        }
Ejemplo n.º 17
0
        public async Task PostEdit([FromBody] AirportModel airport)
        {
            string url = "https://localhost:44393/airports/edit-airport/";

            try
            {
                using (var httpClient = new HttpClient())
                {
                    var stringContent = new StringContent(JsonConvert.SerializeObject(airport), Encoding.UTF8, "application/json");
                    using (var response = await httpClient.PostAsync(url, stringContent))
                    {
                        await response.Content.ReadAsStringAsync();
                    }
                }
            }
            catch (Exception e)
            {
                _logger.LogError("ERROR Editing airport: " + e.Message);
            }
        }
        private bool AddAirport(AirportModel airportModel)
        {
            var editWindow = new EditAirportWindow();
            var ctx        = (EditAirportViewModel)editWindow.DataContext;

            ctx.Airport = airportModel;
            if (editWindow.ShowDialog() != true)
            {
                return(false);
            }

            var errs = GetModelErrors(ctx.Airport);

            if (errs != string.Empty)
            {
                ShowError(errs, "Error! Saving cancelled. ");
                return(false);
            }

            _airportService.AddAirport(airportModel);
            return(true);
        }
Ejemplo n.º 19
0
        private void btnGetAirportInfo_Click(object sender, EventArgs e)
        {
            string    api     = ConfigurationManager.AppSettings["apikey"];
            WebClient web     = new WebClient();
            string    address = string.Empty;

            if (txtAirportCode.Text.Trim() != string.Empty)
            {
                string airportCode = (txtAirportCode.Text.Trim());

                address = "https://iatacodes.org/api/v6/airports.xml?api_key=" + api + "&code=" + airportCode;
            }
            else
            {
                address = "https://iatacodes.org/api/v6/airports.xml?api_key=" + api;
            }
            List <AirportModel> airportList = new List <AirportModel>();
            string      res = web.DownloadString(address);
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(res);
            var nodes = doc.SelectNodes("//response");

            foreach (XmlNode item in nodes)
            {
                if (item.ChildNodes.Count == 2)
                {
                    AirportModel airport = new AirportModel
                    {
                        Code = item.SelectSingleNode("code").InnerText,
                        Name = item.SelectSingleNode("name").InnerText
                    };
                    airportList.Add(airport);
                }
            }

            //var airport = ConvertXMToObject<AirPortResponse>(res);
        }
Ejemplo n.º 20
0
        public void GetListCheck()
        {
            List <AirportModel> test_list = new List <AirportModel>();

            AirportModel air_test1 = new AirportModel
            {
                direction     = "Canada",
                departureTime = new DateTime(2018, 3, 12, 7, 0, 0),
                arriveTime    = new DateTime(2008, 3, 12, 10, 0, 0),
            };

            AirportModel air_test2 = new AirportModel
            {
                direction     = "Italy",
                departureTime = new DateTime(2017, 3, 1, 7, 0, 0),
                arriveTime    = new DateTime(2017, 4, 1, 10, 0, 0),
            };

            test_list.Add(air_test1);
            test_list.Add(air_test2);

            CollectionAssert.IsNotSubsetOf(test_list, m.GetList());
        }
 public ActionResult GetAirport()
 {
     if (Session["role"] != null)
     {
         if ((string)Session["role"] == "admin")
         {
             Repository          r        = new Repository();
             List <Airport>      airports = r.GetAirportDetails();
             List <AirportModel> result   = new List <AirportModel>();
             foreach (Airport a in airports)
             {
                 AirportModel model = new AirportModel();
                 model.AirportCode = a.AirportCode;
                 model.AirportName = a.AirportName;
                 model.Description = a.Description;
                 model.Location    = a.Location;
                 result.Add(model);
             }
             return(View(result));
         }
     }
     return(RedirectToAction("Login", "User"));
 }
Ejemplo n.º 22
0
        public async Task <ActionResult> Airport(int airportId)
        {
            JsonResult result = null;

            try
            {
                var model = new AirportModel();
                await model.Load(AirportBusinessService, airportId);

                var view = await ControllerContext.RenderRazorViewToString("_AirportInformation", model);

                var data = new { Html = view, Airport = model.Airport };

                result = Json(data);
            }
            catch (Exception exception)
            {
                var data = new { Html = exception.Message };

                result = Json(data);
            }

            return(result);
        }
        private bool EditAirport(AirportModel airport)
        {
            var editWindow  = new EditAirportWindow();
            var ctx         = (EditAirportViewModel)editWindow.DataContext;
            var airportCopy = new AirportModel();

            CopyFields(airport, airportCopy);
            ctx.Airport = airportCopy;
            if (editWindow.ShowDialog() != true)
            {
                return(false);
            }
            var errs = GetModelErrors(airportCopy);

            if (errs != string.Empty)
            {
                ShowError(errs, "Error! Saving cancelled. ");
                return(false);
            }

            CopyFields(airportCopy, airport);
            _airportService.EditAirport(airport);
            return(true);
        }
Ejemplo n.º 24
0
        public static Trip GetTrip(int id)
        {
            MySqlConnection currentBDD = new MySqlConnection(ConfigurationManager.ConnectionStrings["connexionString"].ConnectionString);

            currentBDD.Open();

            string sqlselect = "SELECT airport_start_id, airport_end_id, id from trip where id = " + id + ";";

            MySqlCommand    cmd  = new MySqlCommand(sqlselect, currentBDD);
            MySqlDataReader rdr  = cmd.ExecuteReader();
            Trip            trip = new Trip();

            while (rdr.Read())
            {
                trip = new Trip()
                {
                    StartAirport = AirportModel.GetAirport(Convert.ToInt32(rdr[0])), EndAirport = AirportModel.GetAirport(Convert.ToInt32(rdr[1])), Id = Convert.ToInt32(rdr[2])
                };
            }

            rdr.Close();

            return(trip);
        }
Ejemplo n.º 25
0
        private Func <AirportModel, IEnumerable <AirportModel> > ShortestPathFunction(IGraphNetwork graph, AirportModel start)
        {
            var previous = new Dictionary <AirportModel, AirportModel>(new AirportModel.EqualityComparer());
            var queue    = new Queue <AirportModel>();

            queue.Enqueue(start);

            while (queue.Count > 0)
            {
                var vertex = queue.Dequeue();
                foreach (var neighbor in graph.AdjacencyList[vertex])
                {
                    if (previous.ContainsKey(neighbor.Item1))
                    {
                        continue;
                    }

                    previous[neighbor.Item1] = vertex;
                    queue.Enqueue(neighbor.Item1);
                }
            }

            Func <AirportModel, IEnumerable <AirportModel> > shortestPath = v =>
            {
                var path = new List <AirportModel> {
                };

                var current = v;
                while (!current.Equals(start) && previous.Count > 0)
                {
                    path.Add(current);

                    AirportModel previousValue;
                    bool         exist = previous.TryGetValue(current, out previousValue);

                    if (!exist)
                    {
                        throw new NoRouteFoundException();
                    }

                    if (previous[current] != null)
                    {
                        current = previous[current];
                    }
                }
                ;

                path.Add(start);
                path.Reverse();

                return(path);
            };

            return(shortestPath);
        }
Ejemplo n.º 26
0
        //public string GetAirportList2(string _aiportname)
        //{
        //    var query = OME.airports.Where(x => x.name.ToLower().StartsWith(_aiportname.ToLower())
        //    || x.iata_code.StartsWith(_aiportname.ToUpper())
        //     || x.ident.StartsWith(_aiportname.ToUpper())
        //    ).OrderBy(x => x.name);

        //    List<AirportModel> AirportList = new List<AirportModel>();
        //    query.ToList().ForEach(x =>
        //    {
        //        AirportList.Add(new AirportModel
        //        {
        //            id = x.id,
        //            ident = x.ident,
        //            type = x.type,
        //            name = x.name + " (" + x.ident + " | " + x.iata_code + ")",
        //            latitude_deg = x.latitude_deg,
        //            longitude_deg = x.longitude_deg,
        //            elevation_ft = x.elevation_ft,
        //            continent = x.continent,
        //            iso_country = x.iso_country,
        //            iso_region = x.iso_region,
        //            municipality = x.municipality,
        //            scheduled_service = x.scheduled_service,
        //            gps_code = x.gps_code,
        //            iata_code = x.iata_code,
        //            local_code = x.local_code,
        //            home_link = x.home_link,
        //            wikipedia_link = x.wikipedia_link,
        //            keywords = x.keywords,
        //        });
        //    });

        //    TestModel[] Test = new TestModel[] {
        //    new TestModel()
        //    {
        //        page=query.Count(),
        //        total=query.Count(),
        //        records=query.Count(),
        //        airportModelList=AirportList
        //    }
        //};

        //    return new JavaScriptSerializer().Serialize(Test);
        //}


        public AirportModel GetAirportData(string _aiportname)
        {
            //var query = (from a in OME.airports select a).Distinct();
            //linq join in multiple parameters
            //join af in OME.airport_frequencies on new { oId = a.ident, sId = a.iata_code } equals new { oId = af.airport_ident, sId = af.type} into frequencyList
            AirportModel AirportData = (from a in OME.airports
                                        join af in OME.airport_frequencies on a.ident equals af.airport_ident into frequencyList
                                        join runw in OME.runways on a.ident equals runw.airport_ident into runwayList
                                        join nvaids in OME.navaids on a.ident equals nvaids.associated_airport into navaidsList
                                        where a.iata_code.Trim().ToLower() == _aiportname.ToLower() || a.ident.Trim().ToLower() == _aiportname.ToLower()
                                        select new AirportModel
            {
                id = a.id,
                ident = a.ident,
                type = a.type,
                name = a.name + " (" + a.ident + " | " + a.iata_code + ")",
                latitude_deg = a.latitude_deg,
                longitude_deg = a.longitude_deg,
                elevation_ft = a.elevation_ft,
                continent = a.continent,
                iso_country = a.iso_country,
                iso_region = a.iso_region,
                municipality = a.municipality,
                scheduled_service = a.scheduled_service,
                gps_code = a.gps_code,
                iata_code = a.iata_code,
                local_code = a.local_code,
                home_link = a.home_link,
                wikipedia_link = a.wikipedia_link,
                keywords = a.keywords,
                country = OME.countries.Where(c => c.code != null && c.code == a.iso_country).Select(x => x.name).FirstOrDefault(),
                AirportRegion = OME.regions.Where(r => r.code != null && r.code == a.iso_region).Select(x => x.name).FirstOrDefault(),
                frequenciesModelList = frequencyList.Select(x => new airportfrequenciesModel
                {
                    id = x.id,
                    airport_ref = x.airport_ref,
                    airport_ident = x.airport_ident ?? "N/A",
                    type = x.type ?? "N/A",
                    description = x.description ?? "N/A",
                    frequency_mhz = x.frequency_mhz ?? "N/A"
                }).ToList(),
                runwayModelList = runwayList.Select(y => new runwayModel
                {
                    id = y.id,
                    airport_ref = y.airport_ref,
                    airport_ident = y.airport_ident ?? "N/A",
                    length_ft = y.length_ft ?? "N/A",
                    width_ft = y.width_ft ?? "N/A",
                    surface = y.surface ?? "N/A",
                    lighted = y.lighted ?? "N/A",
                    closed = y.closed ?? "N/A",
                    le_ident = y.le_ident ?? "N/A",
                    le_latitude_deg = y.le_latitude_deg ?? "N/A",
                    le_longitude_deg = y.le_longitude_deg ?? "N/A",
                    le_elevation_ft = y.le_elevation_ft ?? "N/A",
                    le_heading_degT = y.le_heading_degT ?? "N/A",
                    le_displaced_threshold_ft = y.le_displaced_threshold_ft ?? "N/A",
                    he_ident = y.he_ident ?? "N/A",
                    he_latitude_deg = y.he_latitude_deg ?? "N/A",
                    he_longitude_deg = y.he_longitude_deg ?? "N/A",
                    he_elevation_ft = y.he_elevation_ft ?? "N/A",
                    he_heading_degT = y.he_heading_degT ?? "N/A",
                    he_displaced_threshold_ft = y.he_displaced_threshold_ft ?? "N/A"
                }).ToList(),
                navaidModelList = navaidsList.Select(z => new navaidModel
                {
                    id = z.id,
                    filename = z.filename ?? "N/A",
                    ident = z.ident ?? "N/A",
                    name = z.name ?? "N/A",
                    type = z.type ?? "N/A",
                    frequency_khz = z.frequency_khz ?? "N/A",
                    latitude_deg = z.latitude_deg ?? "N/A",
                    longitude_deg = z.longitude_deg ?? "N/A",
                    elevation_ft = z.elevation_ft ?? "N/A",
                    iso_country = z.iso_country ?? "N/A",
                    dme_frequency_khz = z.dme_frequency_khz ?? "N/A",
                    dme_channel = z.dme_channel ?? "N/A",
                    dme_latitude_deg = z.dme_latitude_deg ?? "N/A",
                    dme_longitude_deg = z.dme_longitude_deg ?? "N/A",
                    dme_elevation_ft = z.dme_elevation_ft ?? "N/A",
                    slaved_variation_deg = z.slaved_variation_deg ?? "N/A",
                    magnetic_variation_deg = z.magnetic_variation_deg ?? "N/A",
                    usageType = z.usageType ?? "N/A",
                    power = z.power ?? "N/A",
                    associated_airport = z.associated_airport ?? "N/A"
                }).ToList(),

                //runwayModelList = a.runways.Where(x => x.airport_ident == a.ident).ToList().Select(x => new runwayModel {
                //}).ToList(),

                //frequenciesModelList=a.airport_frequencies.Where(y=>y.airport_ident==a.ident).ToList().Select(y=>new airportfrequenciesModel {
                //}).ToList(),
            }).FirstOrDefault();

            return(AirportData);
        }
 public void AcceptAirport(AirportModel airport)
 {
     airports.Add(airport);
 }
Ejemplo n.º 28
0
 public void Update(AirportModel airport)
 {
     this.AirportRepository.Update(airport.GetModel());
     var result = this.UnitOfWork.SaveChanges();
 }
Ejemplo n.º 29
0
        public static List <Trip> GetTrips()
        {
            try
            {
                MySqlConnection currentBDD = new MySqlConnection(ConfigurationManager.ConnectionStrings["connexionString"].ConnectionString);

                List <Trip> trajets = new List <Trip>();

                currentBDD.Open();

                string sqlselect = "SELECT airport_start_id, airport_end_id, id from trip";

                MySqlCommand    cmd = new MySqlCommand(sqlselect, currentBDD);
                MySqlDataReader rdr = cmd.ExecuteReader();

                while (rdr.Read())
                {
                    trajets.Add(new Trip()
                    {
                        StartAirport = AirportModel.GetAirport(Convert.ToInt32(rdr[0])), EndAirport = AirportModel.GetAirport(Convert.ToInt32(rdr[1])), Id = Convert.ToInt32(rdr[2])
                    });
                }

                rdr.Close();

                return(trajets);
            }
            catch
            {
                return(null);
            }
        }
        public static FlightDetail GetFlightDetail(AirportModel departureAirportModel, AirportModel arrivalAirportModel, AircraftModel aircraftModel)
        {
            var detail = new FlightDetail
            {
                DistanceInKm = GPSPositionManager.DistanceInKmBetween(departureAirportModel, arrivalAirportModel)
            };

            detail.FuelNeeded = detail.DistanceInKm * aircraftModel.ConsumptionPerKm + aircraftModel.TakeOffEffort;
            return(detail);
        }