Ejemplo n.º 1
0
        public async Task <IActionResult> SelectMealPartial(int?id)
        {
            var planTask       = _planningService.GetPlan(id);
            var recipesTask    = _recipeService.GetRecipes();
            var mealGroupsTask = _mealGroupService.GetMealGroups();
            await Task.WhenAll(planTask, recipesTask, mealGroupsTask);

            var recipes = recipesTask.Result;
            var plan    = planTask.Result;

            ViewData["RecipeList"] = recipes;
            ViewData["Recipes"]    = new SelectList(recipes, "Id", "Name");
            if (plan == null)
            {
                plan = new MealPlan();
            }
            ViewBag.MealGroups = mealGroupsTask.Result;
            return(PartialView(plan));
        }