Beispiel #1
0
        public void RemoveAll(int restaurantId)
        {
            var restaurant = GetRestaurantById(restaurantId);

            _context.RemoveRange(restaurant.Dishes);
            _context.SaveChanges();
        }
        public void RemoveAll(int restaurantId)
        {
            var dishes = GetRestaurantById(restaurantId).Dishes;

            _dbContext.RemoveRange(dishes);
            _dbContext.SaveChanges();
            return;
        }
Beispiel #3
0
        public void DeleteAllDishes(int restaurantId)
        {
            var restaurant = _context.Restaurants.Include(r => r.Dishes).FirstOrDefault(r => r.Id == restaurantId);

            if (restaurant is null)
            {
                throw new NotFoundException("Restaurant not found");
            }

            _context.RemoveRange(restaurant.Dishes);
            _context.SaveChanges();
        }