public async Task <ActionResult <IngredientDto> > UpdateIngredientAsync(int ingredientId, IngredientForUpdate ingredientForUpdate)
        {
            var ingredientFromRepo = await _ingredients.GetAsync(ingredientId);

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

            _mapper.Map(ingredientForUpdate, ingredientFromRepo);

            _ingredients.Update(ingredientFromRepo);
            await _ingredients.SaveAsync();

            return(Ok(_mapper.Map <Ingredient>(ingredientFromRepo)));
        }
Beispiel #2
0
 public void Update(Ingredient ingredient)
 {
     _dal.Update(ingredient);
 }
        public async Task <int> Update(IngredientsModel ingredients)
        {
            var ingredientsEntity = _mapper.Map <Ingredients>(ingredients);

            return(await _ingredientsRepository.Update(ingredientsEntity));
        }