Exemplo n.º 1
0
        public MyResponse UpdateIngredient(Ingredient ingredient, string userId)
        {
            MyResponse validateResult = ValidateUpdateIngredient(ingredient, userId);

            if (validateResult.IsSuccess())
            {
                _ingredientsRepository.PutIngredient(ingredient);
            }
            return(validateResult);
        }
Exemplo n.º 2
0
    public MyResponse DeleteFavoriteRecipe(FavoriteRecipe favoriteRecipe)
    {
        MyResponse validateResult = ValidateDeleteFavoriteRecipe(favoriteRecipe);

        if (validateResult.IsSuccess())
        {
            _recipesRepository.DeleteFavoriteRecipe(favoriteRecipe);
        }
        return(validateResult);
    }
Exemplo n.º 3
0
    public MyResponse DeleteRecipe(int id, string userId)
    {
        Recipe     recipe         = GetRecipe(id);
        MyResponse validateResult = ValidateDeleteRecipe(recipe, userId);

        if (validateResult.IsSuccess())
        {
            _recipesRepository.DeleteRecipe(recipe);
        }
        return(validateResult);
    }
Exemplo n.º 4
0
        public MyResponse DeleteIngredient(int id, string userId)
        {
            Ingredient ingredient     = GetIngredient(id);
            MyResponse validateResult = ValidateDeleteIngredient(ingredient, id, userId);

            if (validateResult.IsSuccess())
            {
                _ingredientsRepository.DeleteIngredient(ingredient);
            }
            return(validateResult);
        }
Exemplo n.º 5
0
        public MyResponse DeleteRating(int recipeId, string userId)
        {
            Rating     rating         = _ratingsRepository.GetRating(recipeId, userId);
            MyResponse validateResult = ValidateDeleteRating(rating);

            if (validateResult.IsSuccess())
            {
                _ratingsRepository.DeleteRating(rating);
            }
            return(validateResult);
        }
Exemplo n.º 6
0
        public MyResponse DeleteComment(int id, string userId)
        {
            Comment    comment        = _commentsRepository.GetComment(id);
            MyResponse validateResult = ValidateDeleteComment(comment, userId);

            if (validateResult.IsSuccess())
            {
                _commentsRepository.DeleteComment(comment);
            }
            return(validateResult);
        }
Exemplo n.º 7
0
    public MyResponse DeleteRecipe(int id, string userId)
    {
        Recipe     recipe         = GetRecipe(id);
        MyResponse validateResult = ValidateDeleteRecipe(recipe, userId);

        if (validateResult.IsSuccess())
        {
            _recipesRepository.DeleteRecipe(recipe);
            log.Info("UserId: " + userId + " deleted recipe with id: " + id);
        }
        return(validateResult);
    }
Exemplo n.º 8
0
    public MyResponse UpdateRecipe(Recipe recipe, string userId)
    {
        Recipe     recipeFromDb = GetRecipe(recipe.Id);
        MyResponse validResult  = ValidatePutRecipe(recipe, recipeFromDb, userId);

        if (validResult.IsSuccess())
        {
            recipe.UserId    = userId;
            recipe.CreatedOn = recipeFromDb.CreatedOn;
            _recipesRepository.PutRecipe(recipe);
        }
        return(validResult);
    }