public SentRecipe GetRecipeById(int id)
        {
            var recipe = _repo.GetRecipeById(id);

            System.Console.WriteLine("recipe by id: " + recipe.RecipeName);
            return(SentRecipe.GetFromRecipe(recipe));
        }
        public async Task <SentRecipe> SaveRecipePrepare(HistoryModel historyModel)
        {
            Recipe recipe = await _repo.AddNewPrepare(historyModel.recipeId, historyModel.sub);

            if (recipe == null)
            {
                return(null);
            }
            return(SentRecipe.GetFromRecipe(recipe));
        }
        public async Task <SentRecipe> saveRecipe(SentRecipe sentRecipe, string sub)
        {
            Recipe dbRecipe = _repo.GetRecipeById(sentRecipe.RecipeId);

            if (dbRecipe == null)
            {
                dbRecipe = await _repo.SaveNewRecipe(sub);
            }
            Recipe otherRecipe = await _mapSentIntoRecipe(dbRecipe, sentRecipe);

            return(SentRecipe.GetFromRecipe(otherRecipe));
        }
Exemple #4
0
        public void TestGetFromRecipe()
        {
            var recipe = new Recipe()
            {
                RecipeId          = 3,
                RecipeAuthor      = "Anis",
                RecipeDescription = "svsvsvs",
                RecipeIngredients = new List <RecipeIngredient>(),
                RecipeImage       = "Some Image",
                RecipeName        = "Cheese",
                RecipeTags        = new List <RecipeTag>(),
                RecipeAuthors     = new List <RecipeAuthor>(),
                Reviews           = new List <Review>()
            };
            var sentRecipe = SentRecipe.GetFromRecipe(recipe);

            Assert.Equal(recipe.RecipeAuthor, sentRecipe.RecipeAuthor);
        }