Пример #1
0
 public IActionResult Delete(int id)
 {
     try
     {
         _coffeeRepository.DeleteCoffee(id);
         return(NoContent());
     }
     catch (NullReferenceException ex)
     {
         return(NotFound());
     }
 }
        private void RemoveCoffee()
        {
            Coffee[] coffeeList = repository.ReadAll();
            int      id         = userIO.ReadInt("Enter Coffee Id to Delete", 0, 10);

            bool delete = View.ConfirmRemoveCoffee(coffeeList[id]);

            if (delete == true)
            {
                repository.DeleteCoffee(id);
            }
            else
            {
                Console.WriteLine("Nothing was deleted");
            }
        }
Пример #3
0
        public void CanDeleteCoffee()
        {
            Coffee coffee = new Coffee
            {
                CoffeeId     = 2,
                CoffeeName   = "Good Coffee",
                CoffeePrice  = 2.00f,
                CoffeeRating = 9,
                CoffeeRoast  = "Medium"
            };

            repository.CreateCoffee(coffee);
            Coffee newCoffee = repository.ReadById(2);



            repository.DeleteCoffee(2);
            Assert.AreEqual(null, newCoffee.CoffeeName);
        }