public void EditCar() { Console.Clear(); Console.WriteLine("What type of car is this?\n" + "1. Electric\n" + "2. Hybrid\n" + "3. Gas\n" + "4. Cancel\n"); string input = Console.ReadLine(); Console.Clear(); int editInt = int.Parse(input); if (editInt == 1 || editInt == 2 || editInt == 3) { List <Car> search = carRepo.GetCars((CarTypes)editInt - 1); Console.WriteLine("\nEnter the make:"); string make = Console.ReadLine(); Console.WriteLine("\nEnter the model:"); string model = Console.ReadLine(); Console.WriteLine("\nEnter the year:"); int year = int.Parse(Console.ReadLine()); Console.Clear(); foreach (Car car in search) { if (car.Make == make && car.Model == model && car.Year == year) { bool running = true; while (running) { Console.WriteLine("Make\t\tModel\t\tYear\t\tMPG\t\tType\n"); Console.WriteLine(car); Console.WriteLine("\n" + "What would you like to update?\n" + "1. Make\n" + "2. Model\n" + "3. Year\n" + "4. MPG\n" + "5. Type of Car\n" + "6. Delete Car\n" + "7. Nothing\n"); string inputEdit = Console.ReadLine(); Console.Clear(); int edit = int.Parse(inputEdit); if (edit == 1 || edit == 2 || edit == 3 || edit == 4 || edit == 5 || edit == 6) { UpdateCar(car, edit); } else { running = false; break; } } } } Console.Read(); } }
private void EditCar() { Console.Clear(); Console.WriteLine("\nWhat type of car is this?\n" + "[1] Electric\n" + "[2] Hybrid\n" + "[3] Gas\n" + "[4] Cancel\n"); System.ConsoleKeyInfo input = Console.ReadKey(); Console.Clear(); int type = int.Parse(input.KeyChar.ToString()); if (type == 1 || type == 2 || type == 3) { List <Car> search = _carRepo.GetCars((CarTypes)type - 1); Console.WriteLine("\nEnter the make:"); string make = Console.ReadLine(); Console.WriteLine("\nEnter the model:"); string model = Console.ReadLine(); Console.WriteLine("\nEnter the year:"); int year = int.Parse(Console.ReadLine()); Console.Clear(); foreach (Car car in search) { if (car.Make == make && car.Model == model && car.Year == year) { bool loop = true; while (loop) { Console.WriteLine("Make\t\tModel\t\tYear\t\tMPG\t\tType\n"); Console.WriteLine(car); Console.WriteLine("\n" + "What would you like to update?\n" + "[1] Make\n" + "[2] Model\n" + "[3] Year\n" + "[4] Miles per Gallon\n" + "[5] Type of Car\n" + "[6] Delete Car\n" + "[7] Nothing\n"); System.ConsoleKeyInfo editInput = Console.ReadKey(); Console.Clear(); int edit = int.Parse(editInput.KeyChar.ToString()); if (edit == 1 || edit == 2 || edit == 3 || edit == 4 || edit == 5 || edit == 6) { UpdateCar(car, edit); } else { loop = false; break; } } } } Console.Read(); } }