public ActionResult Index(int?year, int?userId) { var model = new HourIndexModel(); var projects = ProjectRepository.ProjectFetchInfoList(); model.UserId = userId ?? ((IBusinessIdentity)Csla.ApplicationContext.User.Identity).UserId; var weeks = WeekCollection.GetWeeks(year ?? DateTime.Now.Year); model.Weeks = weeks; var criteria = new HourDataCriteria { Date = CriteriaHelper.ToDateRangeCriteria(weeks.StartDate, weeks.EndDate), UserId = model.UserId }; var hours = HourRepository.HourFetchInfoList(criteria); model.Hours = hours; model.Year = year ?? DateTime.Now.Year; var years = new List <int>(); for (var currentYear = year ?? DateTime.Now.Year; currentYear <= DateTime.Now.Year; currentYear++) { years.Add(currentYear); } model.Years = years; var users = UserRepository.UserFetchInfoList(projects); model.Users = users; 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)); }