Exemple #1
0
        public ActionResult Detail(int recipeId)
        {
            if (userDAL.GetUser((string)Session[SessionKeys.EmailAddress]) == null)
            {
                return(RedirectToAction("Login", "User"));
            }

            Recipe r = recipeDAL.GetRecipe(recipeId, (int)Session[SessionKeys.UserId]);
            List <RecipeIngredient> recipeIngredients = recipeIngredientDAL.GetRecipeIngredients(recipeId);
            List <PreparationSteps> steps             = preparationStepsDAL.GetPreparationStepsForRecipe(recipeId);

            RecipeViewModel rvm = new RecipeViewModel();

            rvm.RecipeName = r.Name;
            rvm.RecipeId   = r.RecipeId;
            rvm.RecipeCookTimeInMinutes = r.CookTimeInMinutes;
            rvm.RecipeImageName         = r.ImageName;
            rvm.RecipeDescription       = r.Description;
            rvm.RecipeIngredient        = recipeIngredients;

            rvm.PrepSteps = new List <string>();
            if (steps != null)
            {
                foreach (var step in steps)
                {
                    rvm.PrepSteps.Add(step.Steps);
                }
            }



            return(View("Detail", rvm));
        }
        private void GetTop10RecipeDetails(List <RecipeViewModel> listOfRecipesView, List <Recipe> recipes)
        {
            foreach (Recipe recipe in recipes)
            {
                List <RecipeIngredient> recipeIngredients = recipeIngredientDAL.GetRecipeIngredients(recipe.RecipeId);
                List <PreparationSteps> steps             = preparationStepsDAL.GetPreparationStepsForRecipe(recipe.RecipeId);
                RecipeViewModel         rvm = new RecipeViewModel();
                rvm.RecipeName = recipe.Name;
                rvm.RecipeId   = recipe.RecipeId;
                rvm.RecipeCookTimeInMinutes = recipe.CookTimeInMinutes;
                rvm.RecipeImageName         = recipe.ImageName;

                rvm.RecipeIngredient = recipeIngredients;
                //rvm.PrepSteps = new List<string>();
                rvm.PrepSteps = new List <string>();
                if (steps != null)
                {
                    foreach (var step in steps)
                    {
                        rvm.PrepSteps.Add(step.Steps);
                    }
                }
                listOfRecipesView.Add(rvm);
            }
        }