private void ShowStats() { Console.WriteLine("===============Air companies============"); foreach (var x in Companies.Include(a => a.Airplanes)) { Console.WriteLine( $"\n\nname:{x.Name}, country:{x.Country}\nAirplanes\n{string.Join('\n', x.Airplanes)} "); if (x.Airplanes == null) { x.Airplanes = new List <Airplane>(); } } Console.WriteLine("===============Airplanes============"); foreach (var x in Airplanes.Include(a => a.Trips)) { if (x.Trips == null) { x.Trips = new List <Trip>(); } String trips = x.Trips.Count == 0 ? "No flights planned" : $"{string.Join('\n', x.Trips)}"; Console.WriteLine( $"id:{x.AirplaneId}, company:{x.Company}, {x.Manufacturer}-{x.Model}\nTrips\n{trips}"); } }
public void ReturnRentedAirplane(Airplane airplane) { Airplanes.Remove(airplane); Game.Shop.ReturnRent(airplane); UpdateFlights(); }
private void CheckAirplane() { foreach (var x in Airplanes.Include(x => x.Company)) { Console.WriteLine($@"id:{x.AirplaneId}, name:{x.Manufacturer} {x.Model}, country:{x.Company.Name}"); } }
public async Task <IActionResult> Edit(Guid id, [Bind("Id,Model,Seats,Rows,Columns")] Airplanes airplanes) { if (id != airplanes.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(airplanes); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AirplanesExists(airplanes.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(airplanes)); }
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); } } }
public ActionResult Create([Bind(Include = "id,name,AirplaneType,maxpass,size,currentAirport,currentpilot,currentcopilot")] Airplanes airplanes) { if (ModelState.IsValid) { if (db.Airplanes.Any(i => i.id == airplanes.id)) { return(RedirectToAction("Index")); } else { db.Airplanes.Add(airplanes); db.SaveChanges(); } return(RedirectToAction("Index")); } ViewBag.AirplaneType = new SelectList(db.tblAirplaneType, "id", "name", airplanes.AirplaneType); ViewBag.currentAirport = new SelectList(db.Airports, "id", "name", airplanes.currentAirport); ViewBag.currentpilot = new SelectList(db.tblpilots, "id", "name", airplanes.currentpilot); ViewBag.currentcopilot = new SelectList(db.tblpilots, "id", "name", airplanes.currentcopilot); return(View(airplanes)); }
public void Gravar([FromBody] Aviao model) { var aviao = new Airplanes { Id = model.Id, Modelo = model.Modelo, Passageiros = model.Passageiros, Criacao = DateTime.Now, }; regra.Gravar(ref aviao); //if (model.Id == 0) //{ // avioes.Add(new Airplanes // { // Id = avioes.Max(a => a.Id) + 1, // Modelo = model.Modelo, // Passageiros = model.Passageiros, // Criacao = DateTime.Now, // }); //} //else //{ // var aviao = avioes.First(a => a.Id == model.Id); // aviao.Modelo = model.Modelo; // aviao.Passageiros = model.Passageiros; //} }
public ActionResult DeleteConfirmed(int id) { Airplanes airplanes = db.Airplanes.Find(id); db.Airplanes.Remove(airplanes); db.SaveChanges(); return(RedirectToAction("Index")); }
public void RemoveAirplane(int id) { Airplanes.RemoveAll(x => x.Id == id); var serialized = JsonConvert.SerializeObject(Airplanes /*, Formatting.Indented*/); using (var w = new StreamWriter(Path, false)) { w.Write(serialized); } }
internal void AddTrip(String from, String to, DateTime takeof, DateTime arrival, int planeId) { if (arrival > takeof && Airplanes.Find(planeId) != null) { Trips.Add(new Trip { From = from, To = to, Takeof = takeof, Arrival = arrival, AirplaneId = planeId }); } this.SaveChanges(); }
public void SaleAirplane(Airplane airplane) { if (!airplane.InRent) { Airplane plane = Game.Shop.Sale(airplane); Airplanes.Remove(plane); UpdateFlights(); } }
public int IsFollowing(int id) { var status = Airplanes.First(x => x.Id == id).Status; if (status == 2 || status == 16) { return(1); } return(0); }
public bool RemoveAirplane(string id) { Airplane airplaneToRemove = this.FindAirplane(id); if (airplaneToRemove == null) { return(false); } Airplanes.Remove(airplaneToRemove); return(true); }
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); } }
private void SortDB() { Airplanes.Sort(Comparison); 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 async Task <IActionResult> Create([Bind("Id,Model,Seats,Rows,Columns")] Airplanes airplanes) { if (ModelState.IsValid) { airplanes.Id = Guid.NewGuid(); _context.Add(airplanes); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(airplanes)); }
public int UpdateStatus(int id, int status) { try { Airplanes.First(x => x.Id == id).ChangeStatus(status); return(1); } catch { return(0); } }
public string CreateAirplane(string model, string serialNumber) { var airplane = new Airplanes() { Model = model, SerialNumber = serialNumber }; this.context.Airplane.Add(airplane); this.context.SaveChanges(); return(string.Format(OutputMessages.AirPlaneCreated, model)); }
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(); } }
// GET: Airplanes/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Airplanes airplanes = db.Airplanes.Find(id); if (airplanes == null) { return(HttpNotFound()); } return(View(airplanes)); }
public ActionResult Edit([Bind(Include = "id,name,AirplaneType,maxpass,size,currentAirport,currentpilot,currentcopilot")] Airplanes airplanes) { if (ModelState.IsValid) { db.Entry(airplanes).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.AirplaneType = new SelectList(db.tblAirplaneType, "id", "name", airplanes.AirplaneType); ViewBag.currentAirport = new SelectList(db.Airports, "id", "name", airplanes.currentAirport); ViewBag.currentpilot = new SelectList(db.tblpilots, "id", "name", airplanes.currentpilot); ViewBag.currentcopilot = new SelectList(db.tblpilots, "id", "name", airplanes.currentcopilot); return(View(airplanes)); }
private void UnlockPlane(Airplanes id) { for (int i = 0; i < TransportGOController.Instance.PlanesInfo.Length; i++) { if (TransportGOController.Instance.PlanesInfo[i].ID == id) { TransportGOController.Instance.PlanesInfo[i].Locked = false; TransportGOController.Instance.PlanesInfo[i].Buyout = false; } } EventController.Instance.PostEvent("OnSaveData", null); //EventController.Instance.PostEvent("OnHideGUI", null); //EventController.Instance.PostEvent("OnShowAirplaneSelecting", null); }
public IActionResult Index() { Airplanes airplanes = this.context.Airplane.Include(x => x.Flights).First(); List <FlightViewModel> list = new List <FlightViewModel>(); foreach (var airplane in list) { FlightViewModel model = new FlightViewModel() { DepartureDestination = airplane.DepartureDestination, ArrivalDestination = airplane.ArrivalDestination }; list.Add(model); } return(View(list)); }
private void DelAirplane() { Console.WriteLine("============ Delete Airplane:"); CheckAirplane(); Console.WriteLine("In order to delete airplane enter airplane id and press enter"); int pas = int.Parse(Console.ReadLine()); foreach (var x in Airplanes) { if (x.AirplaneId == pas) { Airplanes.Remove(x); } } this.SaveChanges(); MainMenu(); }
// GET: Airplanes/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Airplanes airplanes = db.Airplanes.Find(id); if (airplanes == null) { return(HttpNotFound()); } ViewBag.AirplaneType = new SelectList(db.tblAirplaneType, "id", "name", airplanes.AirplaneType); ViewBag.currentAirport = new SelectList(db.Airports, "id", "name", airplanes.currentAirport); ViewBag.currentpilot = new SelectList(db.tblpilots, "id", "name", airplanes.currentpilot); ViewBag.currentcopilot = new SelectList(db.tblpilots, "id", "name", airplanes.currentcopilot); return(View(airplanes)); }
public static IAirplane CreateAirplane(Airplanes CurrentType) { if (CurrentType == Airplanes.Airliner) { return new CargoAirplane(); } else if (CurrentType == Airplanes.CargoAirplane) { return new Airliner(); } else if (CurrentType == Airplanes.SingleSeater) { return new SingleSeater(); } else { return null; } }
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(); } }
// private void Awake() // { // Instance = this; // } void Awake() { if (TransportGOController.Instance && TransportGOController.Instance.SelectedPlane != Airplanes.None) SpawnAirplane = TransportGOController.Instance.SelectedPlane; int cab = 0; GameObject prefab = null; switch (SpawnAirplane) { case Airplanes.F_16: prefab = F16_Prefab; cab = 0; break; case Airplanes.FA_22: prefab = FA22_Prefab; cab = 1; break; case Airplanes.FA_38: prefab = FA38_Prefab; cab = 2; break; case Airplanes.Mirage: prefab = Mirage_Prefab; break; case Airplanes.SAAB: prefab = SAAB_Prefab; break; } prefab = GameObject.Instantiate(prefab, AirplaneSpawnPoint.position, AirplaneSpawnPoint.localRotation) as GameObject; CameraController.Instance.Target = prefab.transform; var cabin = GameObject.Instantiate(Cabin[cab]) as GameObject; cabin.transform.parent = prefab.transform; cabin.transform.position = prefab.GetComponent<AirplaneDriver>().InsideViewPosition.position; cabin.transform.localRotation = prefab.GetComponent<AirplaneDriver>().InsideViewPosition.localRotation; prefab.GetComponent<AirplaneDriver>().InsideView = cabin.transform; GameObject.Destroy(this); }
public IActionResult Index(Registration model) { Airplanes airplane = new Airplanes() { Model = model.Model, SerialNumber = model.SerialNumber }; RegistrationDetail reg_detail_entity = new RegistrationDetail() { FirstName = model.FirstName, LastName = model.Lastname, Email = model.Email, PhoneNumber = model.Phone, Airplane = airplane }; this.context.Airplane.Add(airplane); this.context.RegistrationDetails.Add(reg_detail_entity); this.context.SaveChanges(); return(View(new Registration())); }
public void AddAirplane(Airplane airplane) { Airplanes.Add(airplane); }
//public ActionResult AirplanesListinTheCurrentAirport(Airports id ) //{ // var query = (from se in db.Airports // join ew in db.Airplanes // on se.id equals ew.currentAirport // select new { Airport = se.name, Airplanes = ew.name }).ToList(); // return View(query); //} public ActionResult TransferAirplane(Airplanes id) { return(View()); }
//Metoda pobierania optymalnego samolotu, wykorzystywana w klasie Flight public Airplane GetAirplane(Route route, DateTime departureTime) { Airplane pom; ReturningAirplane pom2; // Jeżeli dystans jest dłuższy niż 4500km to wybiera samolot AirbusA300 if (route.Distance > 4500) { //Na początek przeszukiwanie listy samolotów powracających ( takie rozwiązanie zostało zaimplementowane //ze względu na konieczność funkcjonalności powielania lotów i wygodę użycia ) pom2 = ReturningAirplanes.FirstOrDefault(x => x.Airplane.GetType() == typeof(AirbusA300)); if (pom2 == null) { //Jeżeli nie znalazło samolotu powracającego to nastąpi przejście do części kodu odpowiedzialnego za dalsze szukanie //na zwykłej liście samolotów } else { //Jeżeli znalazło samolot tego typu to sprawdza czy samolot wróci do bazy przed planowanym odlotem, //jeżeli tak to metoda usunie go z listy samolotów powracających ( tak by się nie dublowały ) i zwraca go int GoIn = DateTime.Compare(pom2.ReturnTime, departureTime); if (GoIn < 0) { ReturningAirplanes.Remove(pom2); return pom2.Airplane; } } //Jeżeli nie znalazło -> szukanie na normalnej liście, jeżeli jest to usunięcie z listy samolotów dostępnych i zwrócenie go pom = Airplanes.FirstOrDefault(x => x.GetType() == typeof(AirbusA300)); if(pom == null) { return null; } Airplanes.Remove(pom); return pom; } // Jeżeli dystans jest Krótszy niż 4500km, ale dłuższy niż 1800km to wybiera samolot Boeing737 else if (route.Distance > 1800) { pom2 = ReturningAirplanes.FirstOrDefault(x => x.Airplane.GetType() == typeof(Boeing737)); if (pom2 == null) { } else { int GoIn = DateTime.Compare(pom2.ReturnTime, departureTime); if (GoIn < 0) { ReturningAirplanes.Remove(pom2); return pom2.Airplane; } } pom = Airplanes.FirstOrDefault(x => x.GetType() == typeof(Boeing737)); if (pom == null) { return null; } Airplanes.Remove(pom); return pom; } // Jeżeli dystans jest krótszy niż 1800km to wybiera samolot Boeing737 else { pom2 = ReturningAirplanes.FirstOrDefault(x => x.Airplane.GetType() == typeof(Tu_134)); if (pom2 == null) { } else { int GoIn = DateTime.Compare(pom2.ReturnTime, departureTime); if (GoIn < 0) { ReturningAirplanes.Remove(pom2); return pom2.Airplane; } } pom = Airplanes.FirstOrDefault(x => x.GetType() == typeof(Tu_134)); if (pom == null) { return null; } Airplanes.Remove(pom); return pom; } }