public IActionResult Get(int id) { var ingredient = _ingredientData.GetById(id); var result = _mapper.Map <ApiIngredient>(ingredient); return(Ok(result)); }
public IActionResult Detail(int ingredientId) { var ingredient = _ingredientData.GetById(ingredientId); var viewModel = new IngredientViewModel { Ingredient = ingredient }; return(View(viewModel)); }
public IActionResult OnGet(int?ingredientId, int recipeId) { var recipe = recipeData.GetById(recipeId); if (ingredientId.HasValue) { Ingredient = ingredientData.GetById(ingredientId.Value); } else { Ingredient = new Ingredient(); Ingredient.RecipeId = recipe.Id; } if (Ingredient == null) { return(RedirectToPage("./NotFound")); } if (Ingredient.RecipeId == recipe.Id) { return(Page()); } else { return(RedirectToPage("/'Notfound")); } return(Page()); }
public IActionResult OnGet(int ingredientId) { Ingredient = ingredientData.GetById(ingredientId); if (Ingredient == null) { return(RedirectToPage("./NotFound")); } return(Page()); }
public IActionResult Index() { if (HttpContext.Session.GetObject <List <int> >("GroceryList") != null) { List <int> sessionList = new List <int>(); sessionList = HttpContext.Session.GetObject <List <int> >("GroceryList"); foreach (var id in sessionList) { GroceryList.IngredientList.Add(_ingredientData.GetById(id)); } } return(View(GroceryList)); }