コード例 #1
0
        public IActionResult Index()
        {
            DashboardViewModel dashboardViewModel = new DashboardViewModel
            {
                RecipeCount = recipeService.CountRecipes(userManager.GetUserId(User)),
                PlanCount   = planService.CountPlans(userManager.GetUserId(User)),
                Plan        = planService.LastPlanDetails(userManager.GetUserId(User))
            };

            if (dashboardViewModel.Plan == null)
            {
                return(View(dashboardViewModel));
            }

            dashboardViewModel.DayNames    = new List <DayName>();
            dashboardViewModel.RecipePlans = recipePlanService.GetAllByPlanIdDisplayOrderAscending(dashboardViewModel.Plan.Id);

            foreach (var recipePlan in dashboardViewModel.RecipePlans)
            {
                if (!dashboardViewModel.DayNames.Contains(recipePlan.DayName))
                {
                    dashboardViewModel.DayNames.Add(recipePlan.DayName);
                }
            }

            return(View(dashboardViewModel));
        }