public IActionResult DeleteRestaurant(int id)
        {
            var restaurantUC = new RestaurantUC(restoRepository);
            var resto        = restaurantUC.GetRestaurantById(id);

            if (resto == null)
            {
                return(RedirectToAction("Error", new { errorMessage = "Sorry! We don't find the restaurant with this Id" }));
            }
            else
            {
                try
                {
                    restaurantUC.DeleteRestaurant(id);
                }
                catch
                {
                    throw new Exception("A problem occured...");
                }
                if (User.IsInRole("Administrators"))
                {
                    return(RedirectToAction("GetAllRestaurantsAdmin"));
                }
                else
                {
                    return(RedirectToAction("GetRestaurantsByRestaurantManager"));
                }
            }
        }
Esempio n. 2
0
        public void DeleteRestaurant_Should_Work()
        {
            //Arrange
            var mock    = new Mock <IRestoRepository>();
            var myResto = new RestoDTO {
                City = "Bruxelles", Id = 1, Name = "R1"
            };

            mock.Setup(x => x.Delete(1));
            RestaurantUC target = new RestaurantUC(mock.Object);

            //Act
            target.DeleteRestaurant(1);

            //Assert
            mock.Verify(u => u.Delete(It.IsAny <int>()), Times.Once());
        }