public void DeleteCar() { Console.Clear(); KomodoLogo(); Console.WriteLine("<<<<<<<< Update Car >>>>>>>"); Console.WriteLine("Enter Make:"); string make = Console.ReadLine(); Console.WriteLine("Enter Model:"); string model = Console.ReadLine(); Console.WriteLine("Enter Year:"); string year = Console.ReadLine(); string oldCarID = year.ToString() + make.ToLower() + model.ToLower(); Car oldCar = _repo.GetCarByID(oldCarID); if (oldCar != null) { Console.Clear(); KomodoLogo(); Console.WriteLine("<<<<<<<< Delete Car >>>>>>>"); DisplayCar(oldCar); Console.WriteLine(); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("!!!!! WARNING DELETE CAN NOT BE UNDONE !!!!! \nDo you want to continue Deleting this item?"); Console.WriteLine("Enter Y to continue deleting this car. Enter N to return to the main menu."); Console.ResetColor(); string deleteConfirm = Console.ReadLine(); if (deleteConfirm.ToLower() == "y") { bool deleteResult = _repo.DeleteCar(oldCar); if (deleteResult == true) { Console.WriteLine("Car deleted Successfully."); Console.WriteLine("Press any key to continue."); } else { Console.WriteLine("Something went wrong. Please try again."); Console.WriteLine("Press any key to continue."); } } else { Console.WriteLine("Delete Canceled. \nPress any Key to return to main menu."); } } else { Console.WriteLine("Car not found. \nPress any key to return to main menu."); } Console.ReadKey(); }
public void DeleteCar() { ushort getId = FindCarByID(); Console.Write("Is this the vehicle you wish to remove? > "); string response = Console.ReadLine(); if (response == "y") { _carRepo.DeleteCar(getId); Console.WriteLine("\nVehicle Removed"); } else { Console.WriteLine("Invalid Response. Return to the menu"); } }
public void DeleteCar()//Delete a car from repo { //Arrange GasCar car = new GasCar("ford", "mustang", 2020); Car_Repo repo = new Car_Repo(); repo.AddCar(car); string id = "2020fordmustang"; //Act Car oldCar = repo.GetCarByID(id); bool removeResult = repo.DeleteCar(oldCar); //Assert Assert.IsTrue(removeResult); }
public void DeletingItems() { CreatingItems(); ushort getId = _carList[1].Id; Car checkObj = _carRepo.GetCarById(getId); Assert.AreEqual(2, getId); //bool isDeleted = _carRepo.DeleteCar(getId); //Assert.IsTrue(isDeleted); _carRepo.DeleteCar(getId); checkObj = _carRepo.GetCarById(getId); Assert.IsNull(checkObj); }