public async Task <int> CreateDish(int restaurantId, CreateDishDTO dto) { var restaurant = await _restaurantRepository.Get(restaurantId); if (restaurant == null) { throw new NotFoundExpection($"Restauracja o id:{restaurantId} nie istnieje "); } var dishEntity = _mapper.Map <Dish>(dto); dishEntity.RestaurantId = restaurantId; var dishid = _dishRepository.Add(dishEntity); return(dishid.Id); }
public async Task <ActionResult> CreateDish([FromRoute] int restaurantId, [FromBody] CreateDishDTO dto) { var newDishId = await _service.CreateDish(restaurantId, dto); return(Created($"api/restaurant/{restaurantId}/dish/{newDishId}", null)); }