public async Task <GetRecipeCategoryDto?> UpdateRecipeCategory(UpdateRecipeCategoryDto updatedRecipeCategory)
        {
            try
            {
                RecipeCategory?recipeCategory = await _context.RecipeCategories.FindAsync(updatedRecipeCategory.Id);

                _mapper.Map(updatedRecipeCategory, recipeCategory);

                await _context.SaveChangesAsync();

                return(_mapper.Map <GetRecipeCategoryDto>(recipeCategory));
            }
            catch (Exception)
            {
                return(null);
            }
        }
Beispiel #2
0
        public async Task <IActionResult> UpdateRecipeCategory(UpdateRecipeCategoryDto updatedRecipe)
        {
            var result = await _recipeCategoryRepository.UpdateRecipeCategory(updatedRecipe);

            return(result != null?Ok(result) : BadRequest());
        }