public async Task <IActionResult> ViewAll() { List <Recipe> recipes = new List <Recipe>(); string user = User.Identity.Name; IEnumerable <SavedRecipe> savedRecipes = await _Context.GetSavedRecipes(user); foreach (SavedRecipe saved in savedRecipes) { Recipe recipe = await _RecipeContext.GetRecipeById(saved.RecipeID); recipes.Add(recipe); } return(View(recipes)); }
public async Task <IActionResult> Edit(int id) { Recipe recipe = await _Recipe.GetRecipeById(id); String user = User.Identity.Name; if (user == recipe.Author) { recipe.Instructions = await _Instruction.GetInstructions(id); recipe.Ingredients = await _Ingredient.GetIngredients(id); return(View(recipe)); } return(RedirectToAction("Index", "Home")); }