public void LoadAirplane() { Airplanes.Clear(); using (SqlConnection conn = new SqlConnection()) { conn.ConnectionString = CONNECTION_STRING; conn.Open(); SqlCommand command = conn.CreateCommand(); command.CommandText = @"SELECT * FROM Airplane"; SqlDataAdapter daAirplane = new SqlDataAdapter(); DataSet dsAirplane = new DataSet(); daAirplane.SelectCommand = command; daAirplane.Fill(dsAirplane, "Airplanes"); foreach (DataRow row in dsAirplane.Tables["Airplanes"].Rows) { Airplane airplane = new Airplane(); airplane.Id = (int)row["Id"]; airplane.Pilot = (string)row["Pilot"]; airplane.Input = (int)row["Input"]; airplane.RowNum = (int)row["RowNum"]; airplane.ColumnNum = (int)row["ColumnNum"]; airplane.BusinessClass = SeatsBusiness((int)row["RowNum"], (int)row["ColumnNum"], (int)row["Input"]); airplane.EconomyClass = SeatsEconomy((int)row["RowNum"], (int)row["ColumnNum"], (int)row["Input"]); airplane.AircompanyName = GetCompanyName((string)row["AircompanyName"]); airplane.Active = (bool)row["Active"]; Airplanes.Add(airplane); } } }
private void AddAirplaneToDB(Airplane airplane) { Airplanes.Add(airplane); var serialized = JsonConvert.SerializeObject(Airplanes /*, Formatting.Indented*/); using (var w = new StreamWriter(Path, false)) { w.Write(serialized); } }
public void BuyAirplane(Airplane airplane) { int price = airplane.PriceBuy; if (Balance >= price) { Airplane plane = Game.Shop.Buy(airplane); Airplanes.Add(plane); UpdateFlights(); } }
public void RentAirplane(Airplane airplane, DateTime dateEnd) { int price = airplane.PriceRent; if (Balance >= price) { dateEnd = dateEnd.EndOfDay(); Airplane plane = Game.Shop.Rent(airplane, dateEnd); Airplanes.Add(plane); UpdateFlights(); } }
public Scenario1() { Airplane1 = new Airplane { Label = "Airplane1" }; Airplane2 = new Airplane { Label = "Airplane2" }; Airplanes.Add(Airplane1); Airplanes.Add(Airplane2); Flights.AddRange(new Flight[] { new Flight { Number = "FLIGHT01", Airplane = Airplane1, Starts = new DateTime(2018, 1, 1, 13, 57, 0), Ends = new DateTime(2018, 1, 1, 15, 33, 0), }, new Flight { Number = "FLIGHT02_COLLIDINGWITH01", Airplane = Airplane1, Starts = new DateTime(2018, 1, 1, 14, 30, 0), Ends = new DateTime(2018, 1, 1, 17, 33, 0), }, new Flight { Number = "FLIGHT03", Airplane = Airplane2, Starts = new DateTime(2018, 1, 1, 14, 30, 0), Ends = new DateTime(2018, 1, 1, 17, 33, 0), } }); foreach (var ap in Airplanes) { ap.Flights = Flights.Where(x => x.Airplane == ap).ToList(); } }
public void AddAirplane(Airplane airplane) { Airplanes.Add(airplane); }