Example #1
0
        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}.");
        }
Example #2
0
        public void UpdateModel(AircraftModel model)
        {
            if (model.Id == 0)
            {
                throw new Exception($"Model {model} does not exist.");
            }

            models[model.Id] = model;
        }
Example #3
0
        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);
        }
Example #4
0
        private AircraftModel GetAircraftModel()
        {
            int           id;
            AircraftModel aircraftModel = null;

            while (aircraftModel == null)
            {
                id            = commandLine.ReadInt("Enter aircraft model id:");
                aircraftModel = aircraftModelManager.GetAircraftModel(id);
            }

            return(aircraftModel);
        }
Example #5
0
 public Airplane(AircraftModel model)
 {
     Model = model;
 }