private void UpdateGreenCarById() { Clear(); WriteLine("\nEnter the Green Car Id to Update."); int oldCarIdUpdate = Int32.Parse(ReadLine()); GreenCars oldGreenCar = _greenCarsRepo.GetGreenCarById(oldCarIdUpdate); GreenCars newGreenCar = new GreenCars(); WriteLine("\nEnter the Car Type Number:" + "\n1. Gas" + "\n2. Hybrid" + "\n3. Electric"); int carTypeNum = Int32.Parse(ReadLine()); newGreenCar.CarType = (CarType)carTypeNum; WriteLine("\nEnter the MPG or Miles Per Charge."); int mpgInput = Int32.Parse(ReadLine()); newGreenCar.Mpg = mpgInput; WriteLine("\nEnter # of Traffic Tickets."); int ticketsInput = Int32.Parse(ReadLine()); newGreenCar.TrafficTickets = ticketsInput; WriteLine("\nEnter # of Miles Driven Per Year."); int milesPerYrInput = Int32.Parse(ReadLine()); newGreenCar.MilesDrivenYr = milesPerYrInput; WriteLine("\nEnter Insurance Rate in Dollars Per Year."); double insRateInput = Double.Parse(ReadLine()); newGreenCar.InsuranceRate = insRateInput; WriteLine("\nEnter the Car's Primary Use Associated #:" + "\n1. Personal" + "\n2. Work" + "\n3. Pleasure"); int carUseNum = Int32.Parse(ReadLine()); newGreenCar.CarUse = (CarUse)carUseNum; newGreenCar.Id = oldGreenCar.Id; bool ifCarUpdated = _greenCarsRepo.UpdateGreenCar(oldCarIdUpdate, newGreenCar); if (ifCarUpdated == true) { WriteLine("\nCar Was Updated."); } else { WriteLine("\nCar Was NOT Updated."); } }
public void UpdateGreenCarTest() { SetContentOneGreenCar(); _testGreenCarsRepo.UpdateGreenCar(greenCar1.Id, greenCar2); GreenCars isGreenCar = _testGreenCarsRepo.GetGreenCarById(greenCar1.Id); Assert.AreEqual(isGreenCar.MilesDrivenYr, greenCar1.MilesDrivenYr); }