//Home/Index public IActionResult Index(int id) { //Initialize week number generator if (WeekNumber.IsLoaded == false) { WeekNumber.WeekGenerator(); WeekNumber.IsLoaded = true; } ; DashboardViewModel dashboardViewModel = new DashboardViewModel(context.Projects.ToList(), id); if (id != 0) { dashboardViewModel.Worktimes = context.Worktimes .Where(w => w.ProjectID == id) .Where(w => w.OpenStatus == true) .Include(w => w.Project) .OrderBy(w => w.WeekRange) .ToList(); dashboardViewModel.DashboardTitle = context.Projects.Single(p => p.ProjectID == id).Name; ViewBag.SingleProject = context.Projects.Include(p => p.Client).Single(p => p.ProjectID == id); } else { dashboardViewModel.Worktimes = context.Worktimes.Where(w => w.OpenStatus == true).OrderBy(w => w.Project.Name).ToList(); dashboardViewModel.DashboardTitle = "Showing all Projects"; dashboardViewModel.SelectProjects.Add(new SelectListItem { Value = "0", Text = "Add Project...", }); } return(View(dashboardViewModel)); }