Exemplo n.º 1
0
        public async Task <IEnumerable <IngredientDto> > GetByDish(int id)
        {
            var ingredients = await _ingredientRepository.GetByDish(id);

            var dto = _mapper.Map <IEnumerable <IngredientDto> >(ingredients);

            return(dto);
        }
Exemplo n.º 2
0
        public async Task AddIngredientToDish(int dishId, int ingredientId)
        {
            var existingIngredients = await _ingredientRepository.GetByDish(dishId);

            if (existingIngredients.Any(i => i.Id == ingredientId))
            {
                throw new BadRequestException("This ingredient is already exist in dish");
            }

            await _dishRepository.AddIngredientToDish(dishId, ingredientId);
        }