public ActionResult Index(string dashboard) { var model = new HomeIndexModel(); model.Tab = "Home"; model.Dashboard = dashboard ?? "My"; model.StartDate = DateTime.Today.ToStartOfWeek(); model.EndDate = DateTime.Today.ToEndOfWeek(); if (model.Dashboard == "Team") { model.Tasks = TaskService.TaskFetchInfoList( new TaskCriteria { IsArchived = false }); model.Hours = HourService.HourFetchInfoList(model.StartDate, model.EndDate); model.Feeds = FeedService.FeedFetchInfoList(5); } else { model.Tasks = MyService.TaskFetchInfoList(); model.Hours = MyService.HourFetchInfoList(model.StartDate, model.EndDate); model.Feeds = MyService.FeedFetchInfoList(5); } return this.View(model); }
public ActionResult Index() { var model = new HomeIndexModel(); var user = UserRepository.UserFetch(); model.User = user; model.StartDate = DateTime.Now.AddDays(-48).ToStartOfWeek(Settings.StartDayOfWeek).Date; model.EndDate = DateTime.Now.ToStartOfWeek(Settings.StartDayOfWeek).Date.AddDays(6); model.Hours = HourRepository.HourFetchInfoList(user, model.StartDate, model.EndDate); model.ProjectListModel = new ProjectListModel { Projects = ProjectRepository.ProjectFetchInfoList() }; model.FeedListModel = new FeedListModel { Feeds = FeedRepository.FeedFetchInfoList(20) }; model.TimelineListModel = new TimelineListModel { Timelines = TimelineRepository.TimelineFetchInfoList(model.User), SourceId = model.User.SourceId, SourceTypeId = (int)model.User.SourceType }; model.CurrentWeekHourSummaryByDateListModel = new HourSummaryByDateListModel { User = user, Hours = this.FetchHoursForWeek( DateTime.Now.ToStartOfWeek(Settings.StartDayOfWeek), model.Hours) }; model.TrailingWeeksHourSummaryByDateListModel = new HourSummaryByDateListModel { User = user, Hours = this.FetchHoursForTrailingWeeks( model.StartDate, model.EndDate, model.Hours) }; var weeks = WeekCollection.GetWeeks(DateTime.Now.Year); var hours = HourRepository.HourFetchInfoList( user, weeks.Min(row => row.StartDate), weeks.Max(row => row.EndDate)); var hourSummaries = new List<HourSummary>(); hourSummaries.Add( new HourSummary { Name = "Week", Value = (double)hours.Where(row => row.Date >= weeks.StartDate.Date && row.Date <= weeks.StartDate.AddDays(6)).Sum(row => row.Duration), NormalValue = 25 }); hourSummaries.Add( new HourSummary { Name = "Year", Value = (double)hours.Sum(row => row.Duration), NormalValue = 1250 }); model.HourSummaryListModel = new HourSummaryListModel { User = user, Hours = hourSummaries }; return View(model); }