Beispiel #1
0
        public async Task <MenuViewModel> GetMenuAsync()
        {
            var model = new MenuViewModel();

            var dishes = await _dbService.GetMattraterAsync();

            foreach (var d in dishes)
            {
                var dish = await ConvertMatrattToDishAsync(d);

                //var ingredients = await _dbService.GetIngredientsAsync(d.MatrattId);
                //foreach (var ingredient in ingredients)
                //{
                //    dish.IngredientsList.Add(ingredient.ProduktNamn);
                //}

                //dish.IngredientsString = string.Join(", ", dish.IngredientsList);

                if (dish.DishType == "Pizza")
                {
                    model.Pizzas.Add(dish);
                }
                else if (dish.DishType == "Sallad")
                {
                    model.Sallads.Add(dish);
                }
                else if (dish.DishType == "Pasta")
                {
                    model.Pasta.Add(dish);
                }
            }
            return(model);
        }
        public async Task <IViewComponentResult> InvokeAsync()
        {
            var model  = new CartViewModel();
            var dishes = await _dbService.GetMattraterAsync();

            foreach (var d in dishes)
            {
                var dish = await _cart.ConvertMatrattToDishAsync(d);

                //var ingredients = await _dbService.GetIngredientsAsync(d.MatrattId);
                //foreach (var ingredient in ingredients)
                //{
                //    dish.IngredientsList.Add(ingredient.ProduktNamn);
                //}

                //dish.IngredientsString = string.Join(", ", dish.IngredientsList);

                model.Dishes.Add(dish);
            }

            model.DishList = new SelectList(model.Dishes, "DishId", "Name");
            return(View(model));
        }