public void CarUpdate() { Console.Clear(); CarsView(); Console.WriteLine("Enter the Model ID of the car you'd like to update."); int originalId = int.Parse(Console.ReadLine()); KomodoGreen updatedCar = new KomodoGreen(); Console.WriteLine("Enter the number assocated with the updated car type.\n" + "1. Electric\n" + "2. Hybrid\n" + "3. Gas"); updatedCar.CarType = (CarTypeEnum)int.Parse(Console.ReadLine()); Console.WriteLine("Enter the updated name of the car."); updatedCar.Name = Console.ReadLine(); Console.WriteLine("Enter the updated details for the car."); updatedCar.Details = Console.ReadLine(); bool wasUpdated = _carRepo.UpdateCar(originalId, updatedCar); if (wasUpdated) { Console.WriteLine("Car was successfully updated!"); } else { Console.WriteLine("Could not be updated. Try again."); } }
public void Arrange() { _carRepo = new KomodoGreenRepo(); _car1 = new KomodoGreen(CarTypeEnum.electric, "Tesla", "It's a Tesla."); _car2 = new KomodoGreen(CarTypeEnum.electric, "Zoom", "It's a Zoom."); _car3 = new KomodoGreen(CarTypeEnum.gas, "Ford", "It's a regular Ford."); _carRepo.AddCar(_car1); _carRepo.AddCar(_car2); _sampleListToAdd.Add(_car3); _listRepo = new KomodoGreenListRepo(); _list1 = new KomodoGreenList(CarListTypeEnum.Electric); _list2 = new KomodoGreenList(CarListTypeEnum.Gas); _listRepo.CreateCarList(_list1); }
public void CarAdd() { Console.Clear(); KomodoGreen newCar = new KomodoGreen(); Console.WriteLine("Enter the number assocated with the car type to be added\n" + "1. Electric\n" + "2. Hybrid\n" + "3. Gas"); newCar.CarType = (CarTypeEnum)int.Parse(Console.ReadLine()); Console.WriteLine("Enter the name of the new car."); newCar.Name = Console.ReadLine(); Console.WriteLine("Enter any details for the new car."); newCar.Details = Console.ReadLine(); _carRepo.AddCar(newCar); }
public void SeedData() { var A = new KomodoGreen(CarTypeEnum.electric, "Tesla", "The it car."); var B = new KomodoGreen(CarTypeEnum.hybrid, "Hyundai", "A reasonable car."); var C = new KomodoGreen(CarTypeEnum.gas, "Ford", "A normal truck."); var D = new KomodoGreen(CarTypeEnum.electric, "BMW", "Looks like it's from the future."); _carRepo.AddCar(A); _carRepo.AddCar(B); _carRepo.AddCar(C); _carRepo.AddCar(D); List <KomodoGreen> electricList = new List <KomodoGreen>(); electricList.Add(A); electricList.Add(D); var A1 = new KomodoGreenList(CarListTypeEnum.Electric, electricList); var B1 = new KomodoGreenList(CarListTypeEnum.Gas); _carListRepo.CreateCarList(A1); _carListRepo.CreateCarList(B1); }
public void CarListUpdate() { Console.Clear(); CarsListView(); Console.WriteLine("Enter the ID of the car list you'd like to update"); int existingCarListId = int.Parse(Console.ReadLine()); KomodoGreenList listToUpdate = _carListRepo.GetCarListById(existingCarListId); Console.WriteLine($"What would you like to update in List ID {listToUpdate.CarListId}? Enter the corresponding number:\n" + $"1. Add car(s) to list\n" + $"2. Remove car from list.\n" + $"3. Update car list type\n"); string input = Console.ReadLine(); switch (input) { case "1": CarsView(); Console.WriteLine($"Please enter the model IDs of the cars you'd like to add to List ID {listToUpdate.CarListId} separated ONLY by commas."); List <string> listOfCarIdsAsString = Console.ReadLine().Split(',').ToList(); var listOfCarsToAdd = new List <KomodoGreen>(); foreach (string idAsString in listOfCarIdsAsString) { int id = int.Parse(idAsString); KomodoGreen carToAdd = _carRepo.GetCarByModelId(id); listOfCarsToAdd.Add(carToAdd); } listToUpdate.AddCarToList(listOfCarsToAdd); Console.WriteLine("To view any changes to car lists, view all car lists in the main menu."); break; case "2": Console.WriteLine($"Please enter the model ID of the car you'd like to delete from List ID {listToUpdate.CarListId}."); listToUpdate.RemoveCarFromList(_carRepo.GetCarByModelId(int.Parse(Console.ReadLine()))); Console.WriteLine("To view any changes to car lists, view all car lists in the main menu."); break; case "3": KomodoGreenList updatedCarList = new KomodoGreenList(); Console.WriteLine("Enter the number assocated with the updated car list.\n" + "1. Electric\n" + "2. Hybrid\n" + "3. Gas"); updatedCarList.CarListType = (CarListTypeEnum)int.Parse(Console.ReadLine()); _carListRepo.UpdateCarList(listToUpdate.CarListId, updatedCarList.CarListType); Console.WriteLine("To view any changes to car lists, view all car lists in the main menu."); break; default: Console.WriteLine("You must enter a valid entry. You will be returned to the main menu."); break; } }