public void EditAirplane() { commandLine.Write("Edit airplane."); commandLine.Write("Enter number in format LL00:"); string number = commandLine.Read().ToUpper(); Airplane airplane = airplaneStore.GetNumber(number); if (airplane == null) { commandLine.Write($"Airplane with number {number} was not found."); return; } AircraftModel aircraftModel = GetAircraftModel(); if (!string.IsNullOrWhiteSpace(aircraftModel.ToString())) { airplane.Model = aircraftModel; } commandLine.Write("Enter airport of origin."); airplane.AirportCode = commandLine.Read().ToUpper(); airplaneStore.UpdateAirplane(airplane); commandLine.Write($"Successfully updated airplane {airplane}."); }
public void UpdateModel(AircraftModel model) { if (model.Id == 0) { throw new Exception($"Model {model} does not exist."); } models[model.Id] = model; }
public void AddModel(AircraftModel model) { if (model.Id != 0) { throw new Exception($"Cannot add model with non-zero id {model.Id}."); } model.Id = GenerateId(); models.Add(model.Id, model); }
private AircraftModel GetAircraftModel() { int id; AircraftModel aircraftModel = null; while (aircraftModel == null) { id = commandLine.ReadInt("Enter aircraft model id:"); aircraftModel = aircraftModelManager.GetAircraftModel(id); } return(aircraftModel); }
public Airplane(AircraftModel model) { Model = model; }