public async Task <IActionResult> PutDish(int restaurantId, int id, DishForUpdateDto dish)
        {
            if (!await _dishesRepository.RestaurantExists(restaurantId))
            {
                return(NotFound());
            }

            var dishFromRepo = await _dishesRepository.GetAsync(restaurantId, id);

            if (dishFromRepo == null)
            {
                return(NotFound());
            }

            _mapper.Map(dish, dishFromRepo);

            _dishesRepository.Update(dishFromRepo);

            if (await _dishesRepository.SaveChangesAsync())
            {
                return(NoContent());
            }

            return(BadRequest());
        }
Beispiel #2
0
        public async Task <IActionResult> Update(int id, DishForUpdateDto dishDto)
        {
            var dishToUpdate = await _repo.GetById <Dish>(id);

            _mapper.Map(dishDto, dishToUpdate);

            _repo.Update(dishToUpdate);

            return(NoContent());
        }