private UserRandomRecipes AddFeelinLuckyToViewObject(UserRandomRecipes finalList, Recipe feelinLucky) { var helperObject = _repo.Recipe.FindByCondition(f => f.RecipeId == feelinLucky.RecipeId).SingleOrDefault(); finalList.FeelinLucky = helperObject; return(finalList); }
private UserRandomRecipes ConvertListToModelViewType(List <Recipe> finalRecipeList) { UserRandomRecipes userRandomRecipes = new UserRandomRecipes() { Recipes = new List <Recipe>() }; List <UserRandomRecipes> rec = new List <UserRandomRecipes>(); foreach (Recipe recipe in finalRecipeList) { userRandomRecipes.Recipes.Add(recipe); rec.Add(userRandomRecipes); } return(userRandomRecipes); }
// GET: CookController // Default view: will show a grid of multiple recipes and cooks you are following public ActionResult Index() { var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier); var selectedCook = _repo.Cook.FindByCondition(r => r.IdentityUserId == userId).SingleOrDefault(); if (selectedCook == null) { return(RedirectToAction("Create")); } else { //This only works if recipes are seeded in the database. //Maybe come back later and make new view for if in case no recipes exist. UserRandomRecipes userRandomRecipes1 = new UserRandomRecipes(); List <Recipe> recipeList = FindMatchingRecipes(FindRecipeTagsMatchingCookTags(FindCookTags(selectedCook))); List <Recipe> finalRecipeList = RandomizeRecipes(recipeList); ConvertListToModelViewType(finalRecipeList); var theActualFinalList = ConvertListToModelViewType(finalRecipeList); var feelinLuckyRecipe = (FindRecipeForFeelinLuckyButton(1)); var theViewObject = AddFeelinLuckyToViewObject(theActualFinalList, feelinLuckyRecipe); return(View(theViewObject)); } }