public void DeleteCustomer() { Customer oldCustomer = new Customer(); Console.Clear(); KomodoLogo(); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("=+= Delete Customer =+="); Console.WriteLine("Enter Full Name of Customer to update:"); string fullName = Console.ReadLine(); oldCustomer = _repo.GetCustomerByFullName(fullName); if (oldCustomer != null) { Console.Clear(); KomodoLogo(); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("=+= Customer to Delete =+="); Console.WriteLine("First Name: " + oldCustomer.FirstName); Console.WriteLine("Last Name: " + oldCustomer.LastName); Console.WriteLine("Customer Type: " + oldCustomer.Type); 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 Item. Enter N to return to the main menu."); Console.ResetColor(); Console.ForegroundColor = ConsoleColor.White; string deleteConfirm = Console.ReadLine(); if (deleteConfirm.ToLower() == "y") { bool deleteResult = _repo.DeleteCustomer(oldCustomer); if (deleteResult == true) { Console.WriteLine("Item 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("Customer not found. Press any key to return to the main menu"); } Console.ReadKey(); }
public void DeleteCustomer_ShouldReturnTrue() //Delete { //Arrange Customer_Repo repo = new Customer_Repo(); Customer customer = new Customer("Hambright", "Josh", CustomerType.Current); repo.AddCustomer(customer); string fullName = "Josh Hambright"; //Act Customer oldCustomer = repo.GetCustomerByFullName(fullName); bool removeCustomer = repo.DeleteCustomer(oldCustomer); //Assert Assert.IsTrue(removeCustomer); }