//Delete Cars private void DeleteCar() { bool inRemoval = true; while (inRemoval) { Console.Clear(); Console.WriteLine("Please choose an option:\n" + "1. Remove a car from a list.\n" + "2. Remove a car from the system.\n" + "3. Go back to the main menu" + "\n"); string input = Console.ReadLine().ToLower(); switch (input) { case "1": //Remove car from list RemoveCarFromList(); break; case "2": //remove car from system RemoveCarFromSystem(); break; case "3": //Exit inRemoval = false; break; default: Console.WriteLine("Please enter a valid number"); break; } void RemoveCarFromList() { Console.Clear(); Console.WriteLine("Please enter the list you wish to edit: electric, hybrid, or gas"); string fuelType = Console.ReadLine().ToLower(); Cars.FuelType car; if (fuelType != null) { if (fuelType == "electric") { car = Cars.FuelType.Electric; List <Cars> listOfCarType = _carRepo.ViewCarByFuelType(car); foreach (Cars carType in listOfCarType) { Console.WriteLine($"Make: {carType.Make.ToUpper()}\n" + $"Model: {carType.Model.ToUpper()}\n" + $"Year: {carType.Year}\n" + $"Fuel Type: {carType.TypeOfFuel}\n" + $"_______________________"); } Console.WriteLine("Please enter the model of the car you wish to remove:"); string model = Console.ReadLine(); Console.WriteLine($"Are you sure you want to remove this from the electric car list?\n" + $"Y or N"); string confirm = Console.ReadLine().ToLower(); if (confirm == "y") { bool wasRemoved = _carRepo.RemoveCarFromTypeList(model, Cars.FuelType.Electric); if (wasRemoved == true) { Console.WriteLine("The car was successfully removed from the system\n" + "Press any key to continue"); Console.ReadKey(); } else { Console.WriteLine("I'm sorry, the removal was unsuccessful."); } } } else if (fuelType == "hybrid") { car = Cars.FuelType.Hybrid; List <Cars> listOfCarType = _carRepo.ViewCarByFuelType(car); foreach (Cars carType in listOfCarType) { Console.WriteLine($"Make: {carType.Make.ToUpper()}\n" + $"Model: {carType.Model.ToUpper()}\n" + $"Year: {carType.Year}\n" + $"Fuel Type: {carType.TypeOfFuel}\n" + $"_______________________"); } Console.WriteLine("Please enter the model of the car you wish to remove:"); string model = Console.ReadLine(); Console.WriteLine($"Are you sure you want to remove this from the hybrid car list?\n" + $"Y or N"); string confirm = Console.ReadLine().ToLower(); if (confirm == "y") { bool wasRemoved = _carRepo.RemoveCarFromTypeList(model, Cars.FuelType.Hybrid); if (wasRemoved == true) { Console.WriteLine("The car was successfully removed from the system\n" + "Press any key to continue"); Console.ReadKey(); } else { Console.WriteLine("I'm sorry, the removal was unsuccessful."); } } } else if (fuelType == "gas") { car = Cars.FuelType.Gas; List <Cars> listOfCarType = _carRepo.ViewCarByFuelType(car); foreach (Cars carType in listOfCarType) { Console.WriteLine($"Make: {carType.Make.ToUpper()}\n" + $"Model: {carType.Model.ToUpper()}\n" + $"Year: {carType.Year}\n" + $"Fuel Type: {carType.TypeOfFuel}\n" + $"_______________________"); } Console.WriteLine("Please enter the model of the car you wish to remove:"); string model = Console.ReadLine(); Console.WriteLine($"Are you sure you want to remove this from the gas car list?\n" + $"Y or N"); string confirm = Console.ReadLine().ToLower(); if (confirm == "y") { bool wasRemoved = _carRepo.RemoveCarFromTypeList(model, Cars.FuelType.Gas); if (wasRemoved == true) { Console.WriteLine("The car was successfully removed from the list\n" + "Press any key to continue"); Console.ReadKey(); } else { Console.WriteLine("I'm sorry, the removal was unsuccessful."); } } } else { Console.WriteLine("We couldn't a find a list by that name. Please try again."); } } } void RemoveCarFromSystem() { Console.Clear(); ViewAllCars(); Console.WriteLine("Please enter the model of the car you wish to remove:"); string model = Console.ReadLine().ToLower(); Cars car = _carRepo.GetCarByModel(model); if (car != null) { Console.WriteLine($"Make: {car.Make.ToUpper()}\n" + $"Model: {car.Model.ToUpper()}\n" + $"Year: {car.Year}\n" + $"Fuel Type: {car.TypeOfFuel}\n" + $"_______________________"); Console.WriteLine($"Are you sure you want to remove this car from the system?\n" + $"Y or N"); string confirm = Console.ReadLine().ToLower(); if (confirm == "y") { bool wasRemoved = _carRepo.RemoveCarFromSystem(model); if (wasRemoved == true) { Console.WriteLine("The car was successfully removed from the system\n" + "Press any key to continue"); Console.ReadKey(); } else { Console.WriteLine("I'm sorry, the removal was unsuccessful."); } } else { Console.WriteLine("There was no car by that model"); } } } } }