private void OnShowFlight() { List <Airports> listaGradovafrom = new List <Airports>(); List <Airports> listaGradovato = new List <Airports>(); List <Routes> ListaRuta = new List <Routes>(); FlightList.Clear(); Airports c = new Airports(); Routes r = new Routes(); listaGradovafrom = c.GetInnerAllFrom(FlFrom); listaGradovato = c.GetInnerAllTo(FlTo); ListaRuta = r.ListOfRoutes(); foreach (var From in listaGradovafrom) { foreach (var To in listaGradovato) { foreach (var rute in ListaRuta) { if (rute.From == From.airIATA && rute.To == To.airIATA) { rute.From = FlFrom; rute.To = FlTo; FlightList.Add(rute); } } } } }
private void ParseAirports() { Airports.Clear(); using (var reader = new StreamReader(string.Format(PathToData, "airports.csv"))) using (var csv = new CsvReader(reader)) { csv.Read(); csv.ReadHeader(); while (csv.Read()) { var airport = new Airport { Name = csv.GetField("Name"), City = csv.GetField("City"), Country = csv.GetField("Country"), IATADesignator = csv.GetField("IATA 3"), Latitude = csv.GetField <double>("Latitute"), Longitude = csv.GetField <double>("Longitude") }; Airports.Add(airport); } } }
private Airports processAirport(string line) { line = line.Trim(); if (line.Length > 0) { string[] col_data = line.Split(','); if (col_data.Length != 2) { throw new Exception("airports file column mismatch"); } Airports a_o = new Airports() { Code = col_data[0], Name = col_data[1], }; if (ParseErrorFlag) { ErrorList.Add(ParseErrorMessage); } return(a_o); } return(null); }
public List <Airports> ReadAirports() { List <Airports> retList = new List <Airports>(); using (var reader = new StreamReader(IntegrationConfig.GetDataLocation() + "Airports.csv")) { int i = 0; while (!reader.EndOfStream) { var line = reader.ReadLine(); var values = line.Split(';'); if (i != 0) { Airports airport = new Airports() { Code = values[0], Name = values[1], City = values[2], Country = values[3] }; retList.Add(airport); } i++; } } return(retList); }
/// <summary> /// Update from Sim Data Event /// Maintain the current Departure Airport - if the ICAO cannot be found it will get N.A. /// /// </summary> /// <param name="icao">The airport ICAO code or an empty string</param> public static void UpdateDep(string icao) { icao = icao.ToUpperInvariant( ); if (icao == DepAirportICAO) { return; // same as before } // then set if a string was given, else we leave it as it was before if (!string.IsNullOrWhiteSpace(icao)) { // first clear all DepAirportICAO = AirportNA_Icao; DepLocation = null; DepAirportName = ""; var apt = Airports.FindAirport(icao); if (apt != null) { // Apt found in DB DepLocation = new LatLon(apt.Lat, apt.Lon, apt.Elevation); DepAirportName = apt.Name; DepAirportICAO = icao; } HasChanged = true; } }
private async Task UpdateMetarInfo(MetarResult response) { IsBusy = false; AirportCode = string.Empty; if (response.StatusCode != System.Net.HttpStatusCode.OK) { DisplayError(Localization.Error_Occured, response.StatusCode.ToString()); return; } var airport = Airport.MapFromResponse(response.AirportIdentifier, response.MetarResponse); var alreadyExists = Airports.FirstOrDefault(x => x.Name == airport.Name); if (alreadyExists == null) { Airports.Add(airport); } else { alreadyExists.Copy(airport); OnPropertyChanged(nameof(Airports)); } HasSavedItems = Airports != null && Airports.Any(); await AirportService.SaveAirport(airport, new System.Threading.CancellationToken()).ConfigureAwait(false); }
public async Task<IActionResult> Edit(int id, [Bind("AirportId,AirportIatacode,AirportIdentifier,AirportTypeId,AirportName,AirportLatitudeDegrees,AirportLongitudeDegrees,AirportElevationFeet,RegionId,AirportMunicipality,AirportScheduledService,AirportGpscode,AirportLocalCode,AirportHomeLink,AirportWikipediaLink,SkyCommOpsLevelId")] Airports airports) { if (id != airports.AirportId) { return NotFound(); } if (ModelState.IsValid) { try { _context.Update(airports); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AirportsExists(airports.AirportId)) { return NotFound(); } else { throw; } } return RedirectToAction(nameof(Index)); } ViewData["AirportTypeId"] = new SelectList(_context.AirportTypes, "AirportTypeId", "AirportType", airports.AirportTypeId); ViewData["RegionId"] = new SelectList(_context.Regions, "RegionId", "RegionCode", airports.RegionId); ViewData["SkyCommOpsLevelId"] = new SelectList(_context.SkyCommOpsLevels, "SkyCommOpsLevelId", "SkyCommOpsLevel", airports.SkyCommOpsLevelId); ViewBag.returnUrl = Request.Headers["Referer"].ToString(); return View(airports); }
public void LoadAirport() { Airports.Clear(); using (SqlConnection conn = new SqlConnection()) { conn.ConnectionString = CONNECTION_STRING; conn.Open(); SqlCommand command = conn.CreateCommand(); command.CommandText = @"SELECT * FROM Airport"; SqlDataAdapter daAirport = new SqlDataAdapter(); DataSet dsAirport = new DataSet(); daAirport.SelectCommand = command; daAirport.Fill(dsAirport, "Airports"); foreach (DataRow row in dsAirport.Tables["Airports"].Rows) { Airport airport = new Airport(); airport.Id = (int)row["Id"]; airport.AirportID = (string)row["AirportID"]; airport.Name = (string)row["Name"]; airport.City = (string)row["City"]; airport.Active = (bool)row["Active"]; Airports.Add(airport); } } }
private void btnRent_Click(object sender, RoutedEventArgs e) { KeyValuePair <DestinationDemand, int> v = (KeyValuePair <DestinationDemand, int>)((Button)sender).Tag; Airport airport = Airports.GetAirport(v.Key.Destination); Boolean hasCheckin = airport.getAirportFacility(GameObject.GetInstance().HumanAirline, AirportFacility.FacilityType.CheckIn).TypeLevel > 0; object o = PopUpAirportContract.ShowPopUp(airport); //WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2222"), string.Format(Translator.GetInstance().GetString("MessageBox", "2222", "message"), airport.Profile.Name), WPFMessageBoxButtons.YesNo); if (o != null) { if (!hasCheckin) { AirportFacility checkinFacility = AirportFacilities.GetFacilities(AirportFacility.FacilityType.CheckIn).Find(f => f.TypeLevel == 1); airport.addAirportFacility(GameObject.GetInstance().HumanAirline, checkinFacility, GameObject.GetInstance().GameTime); AirlineHelpers.AddAirlineInvoice(GameObject.GetInstance().HumanAirline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Purchases, -checkinFacility.Price); } airport.addAirlineContract((AirportContract)o); showDemand(); } }
public IHttpActionResult PutAirports(int id, Airports airports) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != airports.AirportID) { return(BadRequest()); } db.Entry(airports).State = System.Data.Entity.EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!AirportsExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public List <TravelPoint> GetSuggest(string query) { var ports = Airports.Where( c => c.NameEn.ToLower().Contains(query.ToLower()) || c.NameRu.ToLower().Contains(query.ToLower())) .Distinct() .ToList(); var cities = Cities.Where( c => c.NameEn.ToLower().Contains(query.ToLower()) || c.NameRu.ToLower().Contains(query.ToLower())) .Where(c => c.CountryCode == "RU") .Distinct() .OrderByDescending(c => c.Popularity) .ToList(); foreach (var city in cities.Where(c => !string.IsNullOrWhiteSpace(c.CountryCode))) { city.CountryName = Countries.FirstOrDefault(c => c.Code == city.CountryCode).NameRu; } var total = new List <TravelPoint>(); //total.AddRange(ports); total.AddRange(cities); return(total); }
/// <summary> /// Create an airport /// </summary> /// <param name="name"></param> /// <param name="x"></param> /// <param name="y"></param> /// <param name="minPassenger"></param> /// <param name="maxPassenger"></param> /// <param name="minMarchandise"></param> /// <param name="maxMarchandise"></param> public void CreateAirport(string name, int x, int y, int minPassenger, int maxPassenger, int minMarchandise, int maxMarchandise, string dms) { Airport airport = new Airport(name, x, y, minPassenger, maxPassenger, minMarchandise, maxMarchandise, dms); Airports.Add(airport); airportNotifier(airport.ToString()); }
public IObservable <IEnumerable <Flight> > GetFlightsFrom(Airport fromAirport) { var airports = new AirportNamesService().GetAirports(); var airlines = new AirlineNamesService().GetAirlines(); var statuses = new StatusService().GetStautses(); var referenceData = airports .ForkJoin(airlines, (allAirports, allAirlines) => { Airports.AddRange(allAirports); Airlines.AddRange(allAirlines); return(new Unit()); }) .ForkJoin(statuses, (nothing, allStatuses) => { Statuses.AddRange(allStatuses); return(new Unit()); }); string url = string.Format(_serviceUrl, 1, 5, fromAirport.Code); var flights = from data in referenceData from flight in GetFlightsFrom(url) select flight; return(flights); }
//checks an airport for extending of runway public static void CheckForExtendRunway(Airport airport) { int minYearsBetweenExpansions = 5; long maxRunwayLenght = (from r in airport.Runways select r.Length).Max(); long longestRequiredRunwayLenght = AirlinerTypes.GetTypes(a => a.Produced.From <= GameObject.GetInstance().GameTime&& a.Produced.To >= GameObject.GetInstance().GameTime).Max(a => a.MinRunwaylength); var airportRoutes = AirportHelpers.GetAirportRoutes(airport); var routeAirliners = airportRoutes.SelectMany(r => r.getAirliners()); long longestRunwayInUse = routeAirliners.Count() > 0 ? routeAirliners.Max(a => a.Airliner.Type.MinRunwaylength) : 0; if (maxRunwayLenght < longestRequiredRunwayLenght / 2 && maxRunwayLenght < longestRunwayInUse * 3 / 4 && GameObject.GetInstance().GameTime.AddYears(-minYearsBetweenExpansions) > airport.LastExpansionDate) { List <string> runwayNames = (from r in Airports.GetAllAirports().SelectMany(a => a.Runways) select r.Name).Distinct().ToList(); foreach (Runway r in airport.Runways) { runwayNames.Remove(r.Name); } Runway.SurfaceType surface = airport.Runways[0].Surface; long lenght = Math.Min(longestRequiredRunwayLenght * 3 / 4, longestRunwayInUse * 2); Runway runway = new Runway(runwayNames[rnd.Next(runwayNames.Count)], lenght, surface, GameObject.GetInstance().GameTime.AddDays(90), false); airport.Runways.Add(runway); airport.LastExpansionDate = GameObject.GetInstance().GameTime; } }
public ActionResult Create([Bind(Include = "id,name,city")] Airports airports) { if (ModelState.IsValid) { if (db.Airports.Any(i => i.id == airports.id)) { return(RedirectToAction("Index")); } else { db.Airports.Add(airports); db.SaveChanges(); } return(RedirectToAction("Index")); } //else //{ // return RedirectToAction("Index"); //} return(View(airports)); }
public static void ClearAirportStatistics() { foreach (Airport airport in Airports.GetAllAirports()) { airport.Statistics.Stats.Clear(); } }
public HttpResponseMessage AddFlight(HttpRequestMessage request, Flight flight) { if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } if (Airports.IsTheSameAirport(flight) == true) { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } int result = DateTime.Compare(DateTime.Parse(flight.DepartureTime), DateTime.Parse(flight.ArrivalTime)); if (result > 0 || result == 0) { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } lock (locker) { if (FlightStorage.IsSameFlight(flight)) { return(request.CreateResponse(HttpStatusCode.Conflict)); } else { FlightStorage.Add(flight); } } return(request.CreateResponse(HttpStatusCode.Created, flight)); }
private string BuildInsertCmd(Airports airport) { string prefix = "INSERT INTO Airports_2020 (AirportName, AirportCountry, AirportCity, AirportLong, AirportLat, AirportCode) "; string cmdValues = string.Format("VALUES ('{0}','{1}','{2}','{3}','{4}', '{5}')", airport.AirportName, airport.AirportCountry, airport.AirportCity, airport.AirportLong, airport.AirportLat, airport.AirportCode); return(prefix + cmdValues); }
private void btnSearch_Click(object sender, RoutedEventArgs e) { ComboBox cbCountry = UIHelpers.FindChild <ComboBox>(this, "cbCountry"); ComboBox cbRegion = UIHelpers.FindChild <ComboBox>(this, "cbRegion"); TextBox txtText = UIHelpers.FindChild <TextBox>(this, "txtText"); string text = txtText.Text.Trim().ToUpper(); Country country = (Country)cbCountry.SelectedItem; Region region = (Region)cbRegion.SelectedItem; if (text == "112") { GameObject.GetInstance().addHumanMoney(10000000); } var airports = Airports.GetAllActiveAirports().Where(a => (a.Profile.IATACode.ToUpper().StartsWith(text) || a.Profile.ICAOCode.ToUpper().StartsWith(text) || a.Profile.Name.ToUpper().StartsWith(text) || a.Profile.Town.Name.ToUpper().StartsWith(text)) && ((country.Uid == "100" && (region.Uid == "100" || a.Profile.Country.Region == region)) || new CountryCurrentCountryConverter().Convert(a.Profile.Country) as Country == country)); Frame frmContent = UIHelpers.FindChild <Frame>(this, "frmContent"); if (frmContent != null) { frmContent.Navigate(new PageShowAirports(airports.ToList()) { Tag = this.Tag }); } }
//sets up the different scenario setting private static void SetupScenario() { Parallel.ForEach(Airports.GetAllAirports(), airport => { foreach (Airline airline in Airlines.GetAllAirlines()) { foreach (AirportFacility.FacilityType type in Enum.GetValues(typeof(AirportFacility.FacilityType))) { AirportFacility noneFacility = AirportFacilities.GetFacilities(type).Find((delegate(AirportFacility facility) { return(facility.TypeLevel == 0); })); airport.addAirportFacility(airline, noneFacility, GameObject.GetInstance().GameTime); } } AirportHelpers.CreateAirportWeather(airport); }); foreach (Airline airline in Airlines.GetAllAirlines()) { if (airline.IsHuman) { airline.Money = GameObject.GetInstance().StartMoney; } airline.StartMoney = airline.Money; airline.Fees = new AirlineFees(); airline.addAirlinePolicy(new AirlinePolicy("Cancellation Minutes", 150)); } }
public ActionResult DeleteConfirmed(int id) { Airports airports = db.Airports.Find(id); db.Airports.Remove(airports); db.SaveChanges(); return(RedirectToAction("Index")); }
public List <Airport> GetFilteredAirports(string partialName) => //todo WHAT IS LINQ // TODO: use overload of Contains with StringComparison.InvariantCultureIgnoreCase when available Airports .Where(a => a.Location.Name.IndexOf(partialName, StringComparison.InvariantCultureIgnoreCase) != -1 || a.Name.IndexOf(partialName, StringComparison.InvariantCultureIgnoreCase) != -1) .OrderBy(a => a.Location.Name) .ToList();
public static int UpdateAirport(object airportOBJ) { Airports airport = new Airports(); airport.Clone(airportOBJ); airport.Update(); return(airport.Id); }
private void btnSearch_Click(object sender, RoutedEventArgs e) { string searchText = txtTextSearch.Text.ToUpper(); Country country = (Country)cbCountry.SelectedItem; Region region = (Region)cbRegion.SelectedItem; Boolean humansOnly = cbHumanAirports.IsChecked.Value; Boolean hubsOnly = cbHubs.IsChecked.Value; List <Airport> airports = Airports.GetAllActiveAirports(); if (humansOnly) { airports = airports.FindAll(delegate(Airport airport) { return(GameObject.GetInstance().HumanAirline.Airports.Contains(airport)); }); } if (hubsOnly) { airports = airports.FindAll(delegate(Airport airport) { return(airport.IsHub); }); } if (country.Uid != "100") { airports = airports.FindAll(a => ((Country) new CountryCurrentCountryConverter().Convert(a.Profile.Country)) == country || a.Profile.Country == country); //airports.FindAll(delegate(Airport airport) { return airport.Profile.Country == country; }); } if (country.Uid == "100" && region.Uid != "100") { airports = airports.FindAll(delegate(Airport airport) { return(airport.Profile.Country.Region == region); }); } CompareType sizeCompare = (CompareType)(((ComboBoxItem)cbCompareSize.SelectedItem).Tag); GeneralHelpers.Size size = (GeneralHelpers.Size)cbSize.SelectedItem; switch (sizeCompare) { case CompareType.Equal_to: airports = airports.FindAll(a => a.Profile.Size == size); break; case CompareType.Larger_than: airports = airports.FindAll(a => a.Profile.Size > size); break; case CompareType.Lower_than: airports = airports.FindAll(a => a.Profile.Size < size); break; } airports = airports.FindAll(a => a.Profile.Name.ToUpper().Contains(searchText) || a.Profile.ICAOCode.ToUpper().Contains(searchText) || a.Profile.IATACode.ToUpper().Contains(searchText) || a.Profile.Town.Name.ToUpper().Contains(searchText) || ((Country) new CountryCurrentCountryConverter().Convert(a.Profile.Country)).Name.ToUpper().Contains(searchText)); // airports = airports.FindAll((delegate(Airport airport) { return airport.Profile.Name.ToUpper().Contains(searchText) || airport.Profile.ICAOCode.ToUpper().Contains(searchText) || airport.Profile.IATACode.ToUpper().Contains(searchText) || airport.Profile.Town.ToUpper().Contains(searchText) || airport.Profile.Country.Name.ToUpper().Contains(searchText); })); this.ParentPage.showAirports(airports); }
public void LoadAirConnections() { AirConnections = connectionsReader.LoadDatabase(CsvPath); foreach (var conn in AirConnections) { Airports.Add(conn.AirportA); Airports.Add(conn.AirportB); } }
public HttpResponseMessage GetAirport(HttpRequestMessage message, string search) { Airports[] airport = new Airports[Airports.FindAirport(search).Count]; for (int i = 0; i < Airports.FindAirport(search).Count; i++) { airport[i] = Airports.FindAirport(search).ElementAt(i); } return(message.CreateResponse(HttpStatusCode.OK, airport)); }
public void OnAddCity() { bool check = true; //bool logged = false; bool ciname = false; bool coname = false; bool descname = false; if (String.IsNullOrEmpty(CityName)) { ciname = true; check = false; MessageBox.Show("You need to fill City name box to proceed!", "Error!", MessageBoxButton.OK, MessageBoxImage.Error); } if (!ciname && CityName.Length < 2) { check = false; MessageBox.Show("City name must contains 2 caracters at least!", "Error!", MessageBoxButton.OK, MessageBoxImage.Error); } if (String.IsNullOrEmpty(CountryName)) { coname = true; MessageBox.Show("You need to fill Country name box to proceed!", "Error!", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (!coname && CountryName.Length < 2) { check = false; MessageBox.Show("Country name must contains 2 caracters at least!", "Error!", MessageBoxButton.OK, MessageBoxImage.Error); } if (String.IsNullOrEmpty(DescriptCity)) { descname = true; check = false; MessageBox.Show("You need to fill Description box to proceed!", "Error!", MessageBoxButton.OK, MessageBoxImage.Error); } if (!descname && DescriptCity.Length < 2) { check = false; MessageBox.Show("Description must contains 2 caracters at least!", "Error!", MessageBoxButton.OK, MessageBoxImage.Error); } if (check) { City sql = new City(); sql.InserCity(CityName, CountryName, DescriptCity); Airports a = new Airports(); a.SqlAir(); Routes r = new Routes(); r.UpdateNewRoute(CityName); MessageBox.Show("Dodali ste novi grad", "OK", MessageBoxButton.OK, MessageBoxImage.Information); } }
public ActionResult Edit([Bind(Include = "id,name,city")] Airports airports) { if (ModelState.IsValid) { db.Entry(airports).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(airports)); }
public FlightSearchViewModel() { Departure = new Airports(); Destination = new Airports(); ReturnFlight = false; DepartureDate = DateTime.MinValue; ReturnDate = DateTime.MinValue; Passengers = 0; TicketClass = new TicketClass(); }
private async Task DeleteAirport(Airport airport) { if (Airports.Any() && Airports.Contains(airport)) { await AirportService.DeleteAirport(airport.Id, new System.Threading.CancellationToken()).ConfigureAwait(false); Airports.Remove(airport); } HasSavedItems = Airports != null && Airports.Any(); }