Esempio n. 1
0
 public void CreateNewCar(decimal carPrice, string firstName, TypeOfCar carType)
 {
     if (carType == TypeOfCar.Electric)
     {
         ElectricCar electricCar = new ElectricCar();
         electricCar.CarPrice  = carPrice;
         electricCar.CarType   = TypeOfCar.Electric;
         electricCar.FirstName = firstName;
         _electricRepo.Add(electricCar);
     }
     else if (carType == TypeOfCar.Hybrid)
     {
         HybridCar hybridCar = new HybridCar();
         hybridCar.FirstName = firstName;
         hybridCar.CarType   = TypeOfCar.Hybrid;
         hybridCar.CarPrice  = carPrice;
         _hybridRepo.Add(hybridCar);
     }
     else if (carType == TypeOfCar.Gas)
     {
         GasCar gasCar = new GasCar();
         gasCar.CarPrice  = carPrice;
         gasCar.CarType   = TypeOfCar.Gas;
         gasCar.FirstName = firstName;
         _gasRepo.Add(gasCar);
     }
 }
Esempio n. 2
0
 public void UpdateHybridCar(string firstName, HybridCar hCar)
 {
     foreach (HybridCar car in _hybridRepo)
     {
         if (car.FirstName == firstName)
         {
             _hybridRepo.Remove(car);
             _hybridRepo.Add(hCar);
         }
         else
         {
             foreach (ElectricCar carTwo in _electricRepo)
             {
                 if (carTwo.FirstName == firstName)
                 {
                     _electricRepo.Remove(carTwo);
                     _hybridRepo.Add(hCar);
                 }
                 else
                 {
                     foreach (GasCar carThree in _gasRepo)
                     {
                         if (carThree.FirstName == firstName)
                         {
                             _gasRepo.Remove(carThree);
                             _hybridRepo.Add(hCar);
                         }
                     }
                 }
             }
         }
     }
 }