private void RemoveItemFromList() { Console.Clear(); Console.WriteLine("Which item would you like to remove"); List <MenuItem> itemsInList = _repository.GetItems(); int count = 0; foreach (MenuItem item in itemsInList) { count++; Console.WriteLine($"{count}. {item.MealName}"); } int targetItemName = int.Parse(Console.ReadLine()); int targetIndex = targetItemName - 1; if (targetIndex >= 0 && targetIndex < itemsInList.Count()) { MenuItem desiredItem = itemsInList[targetIndex]; if (_repository.DeleteItem(desiredItem.MealName)) { Console.WriteLine($"{desiredItem.MealName} has been removed."); } else { Console.WriteLine("I'm sorry, I can't do that."); } } else { Console.WriteLine("No item has that name"); } Console.ReadKey(); }
public void DeleteItem_ShouldDelete() { bool wasRemoved = _repo.DeleteItem("BlamWhich"); Assert.IsTrue(wasRemoved); }