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)); }
public IActionResult Details(int id) { PlanDetailsViewModel planDetailsViewModel = new PlanDetailsViewModel() { Plan = planService.PlanDetails(id) }; planDetailsViewModel.DayNames = new List <DayName>(); planDetailsViewModel.RecipePlans = recipePlanService.GetAllByPlanIdDisplayOrderAscending(planDetailsViewModel.Plan.Id); foreach (var recipePlan in planDetailsViewModel.RecipePlans) { if (!planDetailsViewModel.DayNames.Contains(recipePlan.DayName)) { planDetailsViewModel.DayNames.Add(recipePlan.DayName); } } return(View(planDetailsViewModel)); }