Ejemplo n.º 1
0
        private MyResponse ValidateUpdateIngredient(Ingredient ingredient, string userId)
        {
            MyResponse response = new MyResponse(false);

            if (!_ingredientsRepository.IsIngredientExists(ingredient.Id))
            {
                response.Message = "Ingredient with id = " + ingredient.Id + " doesn't exist";
            }
            else if (_recipesService.GetRecipe(ingredient.RecipeId).UserId != userId)
            {
                response.Message = "You are not the creator of the recipe associated with this ingredient, update rejected";
            }
            else
            {
                response.Success = true;
            }
            return(response);
        }