Exemplo n.º 1
0
        public void DeleteRestaurant(int id)
        {
            // On supprime l'adresse associée au restaurant, parce qu'on suppose qu'il n'y a qu'un seul restaurant par adresse et qu'on ne manipule jamais les adresses elles-mêmes
            var restaurant = GetRestaurantWithRelations(id);

            _ctx.Remove(restaurant);
            _ctx.Remove(restaurant.Adresse);
            if (restaurant.LastGrade != null)
            {
                _ctx.Remove(restaurant.LastGrade);
            }
            _ctx.SaveChanges();
        }
Exemplo n.º 2
0
        public async Task <User> Delete(int id)
        {
            User userToDelete = await _context.User.FirstOrDefaultAsync(user => user.Id == id);

            _context.Remove(userToDelete);
            await _context.SaveChangesAsync();

            return(userToDelete);
        }
Exemplo n.º 3
0
        public async Task <Order> Delete(int id)
        {
            Order orderToDelete = await _context.Order.FirstOrDefaultAsync(order => order.Id == id);

            _context.Remove(orderToDelete);
            await _context.SaveChangesAsync();

            return(orderToDelete);
        }
        public async Task <Dish> Delete(int id)
        {
            Dish dishToDelete = await _context.Dish.FirstOrDefaultAsync(dish => dish.Id == id);

            _context.Remove(dishToDelete);
            await _context.SaveChangesAsync();

            return(dishToDelete);
        }
        public async Task <Ingredient> Delete(string name)
        {
            Ingredient ingredientToDelete = await _context.Ingredient.FirstOrDefaultAsync(ingredient => ingredient.Name == name);

            _context.Remove(ingredientToDelete);
            await _context.SaveChangesAsync();

            return(ingredientToDelete);
        }
        public async Task <DishType> Delete(string name)
        {
            DishType typeToDelete = await _context.DishType.FirstOrDefaultAsync(type => type.Name == name);

            _context.Remove(typeToDelete);
            await _context.SaveChangesAsync();

            return(typeToDelete);
        }