Ejemplo n.º 1
0
        public IActionResult Get(int id)
        {
            var ingredient = _ingredientData.GetById(id);
            var result     = _mapper.Map <ApiIngredient>(ingredient);

            return(Ok(result));
        }
Ejemplo n.º 2
0
        public IActionResult Detail(int ingredientId)
        {
            var ingredient = _ingredientData.GetById(ingredientId);
            var viewModel  = new IngredientViewModel {
                Ingredient = ingredient
            };

            return(View(viewModel));
        }
Ejemplo n.º 3
0
        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());
        }
Ejemplo n.º 4
0
 public IActionResult OnGet(int ingredientId)
 {
     Ingredient = ingredientData.GetById(ingredientId);
     if (Ingredient == null)
     {
         return(RedirectToPage("./NotFound"));
     }
     return(Page());
 }
Ejemplo n.º 5
0
 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));
 }