Beispiel #1
0
        public async Task <ActionResult <Recipes.Hop> > AddHopToRecipe([FromBody] Recipes.Hop hop, int recipeId)
        {
            try
            {
                var userId = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier).Value;
                var recipe = await _recipeService.GetCachedRecipeById(recipeId);

                if (recipe.UserId != userId)
                {
                    return(Forbid());
                }

                var result = await _recipeService.AddHopToRecipe(hop, recipeId);

                return(Created("", result));
            }
            catch (ExternalServices.RecipeService.RecipeNotFoundException)
            {
                return(NotFound());
            }
        }