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")); }
public async Task <IActionResult> Index() { IEnumerable <Recipe> recipes = await _Recipe.GetRecipes(); foreach (Recipe recipe in recipes) { recipe.Ingredients = await _Ingredient.GetIngredients(recipe.ID); recipe.Instructions = await _Instruction.GetInstructions(recipe.ID); } return(View(recipes)); }
public async Task <ActionResult <IEnumerable <Ingredient> > > GetIngredients() { return(await _ingredient.GetIngredients()); }