private async void Create() { var created = await airportConnector.FlightEndpoint.Create(newFlight); Flights.Add(created); newFlight = new Flight(); RaisePropertyChanged(() => Flights); RaisePropertyChanged(() => NewFlight); }
public void CreateFlight(Airport origin, Airport destination, AircraftType type) { int id = NextAvailiableId(); string name = type.ToString() + id; Aircraft a = new Aircraft(name, origin.Coordinates, type, id); Flight f = new Flight(a, origin, destination, Canv, DateTime.UtcNow); Flights.Add(f); AllFlightsList.Add(f); }
public async Task Search() { Flights.Clear(); List <Flight> tempFlights = await flightService.GetAll(); foreach (var item in tempFlights) { Flights.Add(item); } }
static void Main(string[] args) { // Creating a flight collection. Flights flights = new Flights(); flights.Add(new Flight() { Name = "Flight-1", Company = "Company-1", AirlineCountry = "USA" }); flights.Add(new Flight() { Name = "Flight-2", Company = "Company-1", AirlineCountry = "GERMANY" }); flights.Add(new Flight() { Name = "Flight-3", Company = "Company-2", AirlineCountry = "INDIA" }); flights.Add(new Flight() { Name = "Flight-4", Company = "Company-3", AirlineCountry = "FRANCE" }); // Testing Code var inputData = new StringBuilder(); // Printing Sample Data Console.WriteLine($"Name Company AirlineCountry"); flights.Cast <Flight>().ToList().ForEach(f => { Console.WriteLine($"{f.Name} {f.Company} {f.AirlineCountry}"); }); Test(flights, "Name"); Test(flights, "Company"); Test(flights, "AirlineCountry"); Console.WriteLine("Test Completed!"); Console.WriteLine("press any key to exit."); Console.ReadKey(); }
public Flight CreateFlight(Flight flight) { try { Flights.Add(flight); SaveChanges(); } catch (Exception e) { throw new Exception(e.Message); } return(flight); }
public void UpdateFlightStatus(string id, FlightStatus status) { lock (Flights) { switch (status) { case FlightStatus.New: Flights.Add(new Flight() { FlightId = id, Status = status }); Console.WriteLine($"Added new flight {id}"); break; case FlightStatus.CheckIn: Flights.Find(e => (e.FlightId == id)).Status = status; Console.WriteLine($"Added check-in: {id} - {status}"); break; case FlightStatus.Boarding: var boarding = Flights.Find(e => (e.FlightId == id)); boarding.Status = status; Console.WriteLine($"Added boarding: {id} - {status}"); MqClient.Send( regGrServ, new FlightInfo() { FlightId = id, PassengerCount = boarding.PasCount, BaggageCount = boarding.BagCount, FoodList = new List <Tuple <Food, int> >() { Tuple.Create(Food.Standard, boarding.StandardFood), Tuple.Create(Food.Vegan, boarding.VeganFood), Tuple.Create(Food.Child, boarding.ChildFood), } } ); Console.WriteLine($"Sent to Ground Service: {id}, {boarding.PasCount}, {boarding.BagCount}, {boarding.StandardFood}, {boarding.VeganFood}, {boarding.ChildFood}"); break; case FlightStatus.Departed: Flights.Find(e => (e.FlightId == id)).Status = status; Console.WriteLine($"Added departed: {id} - {status}"); break; default: break; } } }
private void InitFlights() { Flight flight1 = new Flight(); Flight flight2 = new Flight(); flight1.Id = 1; flight2.Id = 2; flight1.FlightNumber = FlightNumbers.Find(f => f.Airline == "EgyAir"); flight2.FlightNumber = FlightNumbers.Find(f => f.Airline == "USAir"); Flights.Add(flight1); Flights.Add(flight2); FlightNumbers.Find(fn => fn.Airline == "EgyAir").Flights = Flights; FlightNumbers.Find(fn => fn.Airline == "USAir").Flights.Add(flight2); }
public async Task <IActionResult> OnGetAsync() { Airports = await _siaDestinationApiService.GetAirports(); if (String.IsNullOrEmpty(Id)) { Flights = _carbonFlightOffsetService.GetAll(); } else { Flights.Add(_carbonFlightOffsetService.Get(Id)); } return(Page()); }
public void AddBaggage(string flightId) { lock (flightLock) { var flight = Flights.Find(e => e.FlightId == flightId); if (flight != null) { flight.Baggage++; return; } Flights.Add(new Flight() { FlightId = flightId, Baggage = 1 }); } }
public void AddPassenger(string flightId, string pasId) { lock (flightLock) { var flight = Flights.Find(e => e.FlightId == flightId); if (flight != null) { flight.Passengers.Add(pasId); return; } var newFlight = new Flight() { FlightId = flightId }; newFlight.Passengers.Add(pasId); Flights.Add(newFlight); } }
/// <summary> /// This method is called every time the timer event is raised. /// </summary> private void GenerateFlight(object sender, ElapsedEventArgs e) { Random random = new Random(); if (Flights.Count < Configuration.MaxFlights) { StateType stateType = (StateType)random.Next(0, 2); string flightId = GenerateFlightId(); var flight = new Flight(flightId, stateType); Flights.Add(flight); Console.WriteLine($"Flight {flight.Id} was generated | Current flights: {Flights.Count}\n"); flight.InitialteFlight(); return; } Console.WriteLine($"There can be just {Configuration.MaxFlights} in the airport at once.\n"); }
private async void LoadFlightData() { if (this._flights.Count != 0) { return; } Uri dataUri = new Uri("ms-appx:///DataModel/FlightData.json"); StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(dataUri); string jsonText = await FileIO.ReadTextAsync(file); JsonObject jsonObject = JsonObject.Parse(jsonText); JsonArray jsonArray = jsonObject["Flights"].GetArray(); double minPrice = 0; double maxPrice = 0; foreach (JsonValue flight in jsonArray) { JsonObject flightObject = flight.GetObject(); Flights.Add(new FlightDataItem(flightObject["DepartureCity"].GetString(), flightObject["DestinationCity"].GetString(), flightObject["Price"].GetNumber(), flightObject["DepartureTime"].GetString(), flightObject["ArrivalTime"].GetString(), Convert.ToInt32(flightObject["NumberOfConnections"].GetNumber()))); if (minPrice == 0 || flightObject["Price"].GetNumber() < minPrice) { minPrice = flightObject["Price"].GetNumber(); } if (maxPrice == 0 || flightObject["Price"].GetNumber() > maxPrice) { maxPrice = flightObject["Price"].GetNumber(); } } SelectedPrice = maxPrice; }
private static void AddNewIncomingFlightCommand(Flight obj) { var flight = new Flight { FlightNumber = CurrentIncomingFlight.FlightNumber, FlightState = FlightState.Incoming, BaggageCount = CurrentIncomingFlight.BaggageCount, Gate = CurrentIncomingFlight.Gate, PickUpArea = CurrentIncomingFlight.PickUpArea, TimeToFlightSinceSimulationStart = CurrentIncomingFlight.TimeToFlightSinceSimulationStart }; if (!FlightWithNumberExists(IncomingFlights, CurrentIncomingFlight.FlightNumber)) { IncomingFlights.Add(flight); Flights.Add(flight); return; } MessageBox.Show($"An incoming flight with number {CurrentIncomingFlight.FlightNumber} already exists!"); }
private static void AddNewOutgoingFlightCommand(Flight obj) { var flight = new Flight { FlightNumber = CurrentOutgoingFlight.FlightNumber, FlightState = FlightState.WaitingForPreparation, BaggageCount = CurrentOutgoingFlight.BaggageCount, Gate = CurrentOutgoingFlight.Gate, TimeToFlightSinceSimulationStart = CurrentOutgoingFlight.TimeToFlightSinceSimulationStart, TimeToFlightPreparationSinceSimulationStart = CurrentOutgoingFlight.TimeToFlightPreparationSinceSimulationStart }; if (!FlightWithNumberExists(OutgoingFlights, CurrentOutgoingFlight.FlightNumber)) { OutgoingFlights.Add(flight); Flights.Add(flight); return; } MessageBox.Show($"An outgoing flight with number {CurrentOutgoingFlight.FlightNumber} already exists!"); }
private void CmdAnalizeNow_Execute(object obj) { var filePath = DialogTools.ShowFolderPickerDialog("Select the images folder"); if (!string.IsNullOrEmpty(filePath)) { var wdw = new AnalyzeImages() { FilePath = filePath, Owner = this }; wdw.ShowDialog(); var missingLocations = wdw.DetectedFires.Where((f) => f.Longitude == 0 && f.Latitude == 0); if (missingLocations.Any()) { var imageLocation = ResolveLocation.Resolve(true); if (imageLocation != null) { foreach (var l in missingLocations) { l.Latitude = imageLocation[0]; l.Longitude = imageLocation[1]; } } } var flight = new Flight(wdw.DetectedFires, wdw.CoveredArea, filePath, new MapModel(BmpPlanner)); Flights.Add(flight); NotifyPropertyChanged("Flights"); AreasOfInterest.AddToAnalizedArea(flight); AreasOfInterest.NotifyAllPropertyChanged("AnalizedAreaPercentage"); NotifyPropertyChanged("AreasOfInterest"); wdw.Close(); RenderMap(); } }
private async void FillAdditionalCollections() { var flights = await FService.GetEntities(); foreach (var item in flights) { Flights.Add(item); } var crews = await CService.GetEntities(); foreach (var item in crews) { Crews.Add(item); } var planes = await PService.GetEntities(); foreach (var item in planes) { Planes.Add(item); } }
public void LoadFlights() { Flights.Clear(); using (SqlConnection conn = new SqlConnection()) { conn.ConnectionString = CONNECTION_STRING; conn.Open(); SqlCommand command = conn.CreateCommand(); command.CommandText = @"SELECT * FROM Flight"; SqlDataAdapter daFlight = new SqlDataAdapter(); DataSet dsFlight = new DataSet(); daFlight.SelectCommand = command; daFlight.Fill(dsFlight, "Flights"); foreach (DataRow row in dsFlight.Tables["Flights"].Rows) { Flight flight = new Flight(); flight.Id = (int)row["Id"]; flight.FlightNumber = (string)row["FlightNumber"]; flight.AirplaneId = GetAirplanePilot((string)row["AirplaneId"]); flight.DepartureTime = (DateTime)row["DepartureTime"]; flight.ArrivalTime = (DateTime)row["ArrivalTime"]; flight.DeparturePlace = AirportCity((string)row["DeparturePlace"]); flight.Destination = AirportCity((string)row["Destination"]); flight.OneWayTicketPrice = (decimal)row["OneWayTicketPrice"]; flight.CompanyPassword = GetPass((string)row["CompanyPassword"]); flight.Active = (bool)row["Active"]; Flights.Add(flight); } } }
internal Flight addFlight(Flight flight) { Flights.Add(flight); this.SaveChanges(); return(flight); }
public AirportDbContext(DbContextOptions <AirportDbContext> options) : base(options) { Database.EnsureCreated(); if (Flights.CountAsync().Result == 0) { var item = new Flight() { AircraftType = "Boeing 777 Jet", FromLocation = "København", ToLocation = "Amsterdam", DepartureTime = DateTime.Now, ArrivalTime = DateTime.Now }; Flights.Add(item); SaveChanges(); item = new Flight() { AircraftType = "Boeing 747 Jet", FromLocation = "København", ToLocation = "Rom", DepartureTime = DateTime.Now, ArrivalTime = DateTime.Now }; Flights.Add(item); SaveChanges(); item = new Flight() { AircraftType = "Boeing 777 Jet", FromLocation = "København", ToLocation = "Paris", DepartureTime = DateTime.Now, ArrivalTime = DateTime.Now }; Flights.Add(item); SaveChanges(); item = new Flight() { AircraftType = "Boeing 777 Jet", FromLocation = "København", ToLocation = "Berlin", DepartureTime = DateTime.Now, ArrivalTime = DateTime.Now }; Flights.Add(item); SaveChanges(); item = new Flight() { AircraftType = "Boeing 777 Jet", FromLocation = "København", ToLocation = "Madrid", DepartureTime = DateTime.Now, ArrivalTime = DateTime.Now }; Flights.Add(item); SaveChanges(); } }
private void registerFlightButton_Click(object sender, EventArgs e) { if (!System.Text.RegularExpressions.Regex.IsMatch(originTextBox.Text, "^[a-zA-Z]")) { newFlightErrorProvider.SetError(originTextBox, "Solo caracteres alfabeticos en el origen"); } else if (originTextBox.Text.Length > 1) { newFlightErrorProvider.SetError(originTextBox, "Solo un caracter en el origen"); } else if (!System.Text.RegularExpressions.Regex.IsMatch(destinyTextBox.Text, "^[a-zA-Z]")) { newFlightErrorProvider.SetError(destinyTextBox, "Solo caracteres alfabeticos en el destino"); } else if (destinyTextBox.Text.Length > 1) { newFlightErrorProvider.SetError(destinyTextBox, "Solo un caracter en el destino"); } else if (!System.Text.RegularExpressions.Regex.IsMatch(costTextBox.Text, "^[0-9]")) { newFlightErrorProvider.SetError(costTextBox, "Solo caracteres numericos en el costo"); } else if (!System.Text.RegularExpressions.Regex.IsMatch(timeTextBox.Text, "^[0-9]")) { newFlightErrorProvider.SetError(timeTextBox, "Solo caracteres numericos en el tiempo"); } else if (originTextBox.Text.Length == 0 || destinyTextBox.Text.Length == 0 || costTextBox.Text.Length == 0 || timeTextBox.TextLength == 0) { newFlightErrorProvider.SetError(registerFlightButton, "Los campos no pueden estar vacios"); } else if (originTextBox.Text == destinyTextBox.Text) { newFlightErrorProvider.SetError(registerFlightButton, "No se puede ir del mismo origen al mismo destino"); } else { Flight flight = new Flight(originTextBox.Text, destinyTextBox.Text, Int32.Parse(costTextBox.Text), Int32.Parse(timeTextBox.Text)); FlightList aux = Flights.muntipleSearch(1, flight.Route); if (aux.Count > 0) { newFlightErrorProvider.SetError(registerFlightButton, "El vuelo ya existe"); flight = null; } else { Flights.Add(flight); FlightsGraph.addNode(flight.Origin[0]); FlightsGraph.addNode(flight.Destiny[0]); Node aux1 = FlightsGraph.searchNode(flight.Origin[0]); Node aux2 = FlightsGraph.searchNode(flight.Destiny[0]); if (aux1.City != '@' && aux2.City != '@') { FlightsGraph.addEdge(aux1, aux2, flight.Cost); if (aux1.X == null) { GraphForm graphForm = new GraphForm(aux1, FlightsGraph); graphForm.ShowDialog(); } if (aux2.X == null) { GraphForm graphForm = new GraphForm(aux2, FlightsGraph); graphForm.ShowDialog(); } } this.Close(); } } }
private void GuiUpdater(string msg) { App.Current.Dispatcher.Invoke( () => { Console.WriteLine(msg); // Example string: F4716:(Bananen,Autoreifen,);(Autoreifen,,) string[] split = msg.Split(':'); /* split = * [0] F4716 * [1] (Bananen,Autoreifen,);(Autoreifen,,) */ Flug newFlight = new Flug() { Flugnummer = split[0], Containerliste = new ObservableCollection <Container>() }; // Alten Flug rauslöschen da neuer reingekommen ist: foreach (var flug in Flights) { if (flug.Flugnummer.Equals(split[0])) { Flights.Remove(flug); break; } } string[] splitContainer = split[1].Split(';'); /* splitContainer = * [0] (Bananen,Autoreifen,) * [1] (Autoreifen,,) */ foreach (var item in splitContainer) { string CleanCont = item.Replace("{", ""); // "{" entfernen CleanCont = CleanCont.Replace("}", ""); // "}" entfernen string[] splitFreight = CleanCont.Split(','); // splitten je "," -> [0] Bananen [1] Autoreifen ObservableCollection <Produkt> Produktsammlung = new ObservableCollection <Produkt>(); Produktsammlung.Add(new Produkt() { Produktname = splitFreight[0] }); if (!splitFreight[1].Equals("")) { Produktsammlung.Add(new Produkt() { Produktname = splitFreight[1] }); if (!splitFreight[2].Equals("")) { Produktsammlung.Add(new Produkt() { Produktname = splitFreight[2] }); } } Container newcontainer = new Container(); newcontainer.Produkte = Produktsammlung; newFlight.Containerliste.Add(newcontainer); } newFlight.Containeranzahl = newFlight.Containerliste.Count(); Flights.Add(newFlight); ProduktanzahlBerechnen(); }); }
public void AddFlight(Flight flight) { flight.UserId = User.id; Flights.Add(flight); }
public void TakeFromFlightBoard(Flight flight) { Flight taken = Game.FlightBoard.TakeFlight(flight); Flights.Add(taken); }
/*************** Client interface methods **************************/ public bool AddSeats(Transaction context, String flight, int flightSeats, int flightPrice) { return(Flights.Add(context, RID.forFlight(flight), flightSeats, flightPrice)); }
public FlightRoute(Tuple <string, string> startingRoute) { Flights.Add(startingRoute); }