public static WorkerTimesheetApproverViewModel CreateWeeklyTimesheetMoveForward(DateTime selectedDate, DayOfWeek weekStartDay)
        {
            int frequency = 7;
            var timesheet = new WorkerTimesheetApproverViewModel { CalendarDays = new List<DateTime>() };

            var weekStartDayNumber = (int)weekStartDay;
            var dayDiff = (int)selectedDate.DayOfWeek - weekStartDayNumber;

            var periodEndDate = dayDiff >= 0 ? selectedDate.AddDays(6 - dayDiff) : selectedDate.AddDays(-1 - dayDiff);

            timesheet.PeriodEndDate = periodEndDate;
            for (var day = periodEndDate.AddDays(1 - frequency); day <= periodEndDate; day = day.AddDays(1))
            {
                timesheet.CalendarDays.Add(day);
            }
            return timesheet;
        }
        public static void BuildSampleData(WorkerTimesheetApproverViewModel wts)
        {
            wts.WorkerId = 999888;
            wts.PeriodEndDate = new DateTime(2015, 05, 11);
            wts.TimesheetFrequency = TimesheetFrequency.Weekly;
            wts.WorkerFirstName = "Justin";
            wts.WorkerLastName = "Saraceno";
            wts.Engagements = new List<EngagementApprovalViewModel>
                                             {
                                                 new EngagementApprovalViewModel
                                                     {
                                                         AvailableAllocationTypes = new List<AllocationTypeDefinition>()
                                                                                          {
                                                                                            new AllocationTypeDefinition() { Name = "Engagement", AllocationType = AllocationType.Engagement },
                                                                                            new AllocationTypeDefinition() { Name = "Project", AllocationType = AllocationType.Project },
                                                                                            new AllocationTypeDefinition() { Name = "Billing Rule", AllocationType = AllocationType.BillingRule },
                                                                                            new AllocationTypeDefinition() { Name = "Cost Center", AllocationType = AllocationType.CostCenter },
                                                                                            new AllocationTypeDefinition() { Name = "General Ledger", AllocationType = AllocationType.GeneralLedger },
                                                                                          },
                                                        AvailableRateTypes = new List<RateType>
                                                                                 {
                                                                                     new RateType
                                                                                         {
                                                                                            Name = "Client"
                                                                                         },
                                                                                     new RateType
                                                                                         {
                                                                                            Name = "Vendor"
                                                                                         }
                                                                                 },
                                                        Comments = new List<TimesheetCommentViewModel>
                                                                        {
                                                                            new TimesheetCommentViewModel
                                                                                {
                                                                                    CommentText = "Comment One.",
                                                                                    CreatedByFirstName = "Jane",
                                                                                    CreatedByLastName = "Doe",
                                                                                    CreatedDate = new DateTime(2015, 05, 12, 13, 33, 52),
                                                                                    TimesheetCommentId = 1
                                                                                },
                                                                            new TimesheetCommentViewModel
                                                                            {
                                                                                CommentText = "Comment Two.",
                                                                                CreatedByFirstName = "Jon",
                                                                                CreatedByLastName = "Doe",
                                                                                CreatedDate = new DateTime(2015, 05, 13, 16, 01, 04),
                                                                                TimesheetCommentId = 2
                                                                            }
                                                                        },
                                                        SubmittedByFirstName = "Justin",
                                                        SubmittedByLastName = "Saraceno",
                                                        SubmittedDateTime = new DateTime(2015, 05, 10, 17, 03, 09),
                                                        TimesheetStatus = new TimesheetStatus { Name = "Submitted" },
                                                        Workdays = new List<WorkdayViewModel>
                                                                       {
                                                                           new WorkdayViewModel
                                                                               {
                                                                                   WorkDate = new DateTime(2015, 05, 06),
                                                                                   TimeEntries = new List<TimeEntryViewModel>
                                                                                                     {
                                                                                                         new TimeEntryViewModel
                                                                                                             {
                                                                                                                 TimeEntryId = 100,
                                                                                                                TimeEntryDate = new DateTime(2015, 05, 06),
                                                                                                                 TimeEntryKey = new TimesheetEntrySummaryLineKey
                                                                                                              {
                                                                                                                  EngagementId=5000,
                                                                                                                  BillingRuleId = 111,
                                                                                                                  CostCenterId = 111,
                                                                                                                  GeneralLedgerId = 111,
                                                                                                                  ProjectId = 111
                                                                                                              },
                                                                                                                 EngagementName = "Farm Hand: Strawberry Picker 1",
                                                                                                                 ProjectName = "Spring 2015 Season",
                                                                                                                 CostCenterName = "AAA111",
                                                                                                                 GeneralLedgerName = "BBB111",
                                                                                                                 BillingRule = "Standard Time",
                                                                                                                 Rates = new List<RateViewModel>
                                                                                                                             {
                                                                                                                                 new RateViewModel
                                                                                                                                     {
                                                                                                                                         RateId = 100,
                                                                                                                                         RateType = new RateType{ Name = "Client" },
                                                                                                                                         RateAmount = 8.6m,
                                                                                                                                         Total = 80.6m
                                                                                                                                     },
                                                                                                                                  new RateViewModel
                                                                                                                                      {
                                                                                                                                          RateId = 200,
                                                                                                                                          RateType = new RateType{ Name = "Vendor" },
                                                                                                                                          RateAmount = 5.5m,
                                                                                                                                          Total = 50.5m
                                                                                                                                      }
                                                                                                                             },
                                                                                                                EntryType = EntryTypeEnum.Amount,
                                                                                                                Amount = 10m
                                                                                                             }
                                                                                                     }
                                                                               },
                                                                               new WorkdayViewModel
                                                                               {
                                                                                   WorkDate = new DateTime(2015, 05, 07),
                                                                                   TimeEntries = new List<TimeEntryViewModel>
                                                                                                     {
                                                                                                             new TimeEntryViewModel
                                                                                                             {
                                                                                                                 TimeEntryId = 130,
                                                                                                                 TimeEntryDate = new DateTime(2015, 05, 7),
                                                                                                                 TimeEntryKey = new TimesheetEntrySummaryLineKey
                                                                                                              {
                                                                                                                  EngagementId=5000,
                                                                                                                  BillingRuleId = 111,
                                                                                                                  CostCenterId = 111,
                                                                                                                  GeneralLedgerId = 111,
                                                                                                                  ProjectId = 111
                                                                                                              },
                                                                                                                 EngagementName = "Farm Hand: Peach Picker 3",
                                                                                                                 ProjectName = "Summer 2015 Season",
                                                                                                                 CostCenterName = "AAA222",
                                                                                                                 GeneralLedgerName = "BBB222",
                                                                                                                 BillingRule = "Standard Time",
                                                                                                                 Rates = new List<RateViewModel>
                                                                                                                             {
                                                                                                                                 new RateViewModel
                                                                                                                                     {
                                                                                                                                         RateId = 100,
                                                                                                                                         RateType = new RateType{ Name = "Client" },
                                                                                                                                         RateAmount = 10m,
                                                                                                                                         Total = 11m
                                                                                                                                     },
                                                                                                                                  new RateViewModel
                                                                                                                                      {
                                                                                                                                          RateId = 200,
                                                                                                                                          RateType = new RateType{ Name = "Vendor" },
                                                                                                                                          RateAmount = 10m,
                                                                                                                                          Total = 12m
                                                                                                                                      }
                                                                                                                             },
                                                                                                                EntryType = EntryTypeEnum.Amount,
                                                                                                                StartTime = new DateTime(2015,5,9,15,0,0,0),
                                                                                                                EndTime = new DateTime(2015,5,9,18,0,0,0),
                                                                                                                Amount = 3m
                                                                                                             },
                                                                                                         new TimeEntryViewModel
                                                                                                             {
                                                                                                                 TimeEntryId = 110,
                                                                                                                 TimeEntryDate = new DateTime(2015, 05, 07),
                                                                                                                 TimeEntryKey = new TimesheetEntrySummaryLineKey
                                                                                                              {
                                                                                                                  EngagementId=5000,
                                                                                                                  BillingRuleId = 111,
                                                                                                                  CostCenterId = 111,
                                                                                                                  GeneralLedgerId = 111,
                                                                                                                  ProjectId = 111
                                                                                                              },
                                                                                                                 EngagementName = "Farm Hand: Strawberry Picker 1",
                                                                                                                 ProjectName = "Spring 2015 Season",
                                                                                                                 CostCenterName = "AAA111",
                                                                                                                 GeneralLedgerName = "BBB111",
                                                                                                                 BillingRule = "Standard Time",
                                                                                                                 Rates = new List<RateViewModel>
                                                                                                                             {
                                                                                                                                 new RateViewModel
                                                                                                                                     {
                                                                                                                                         RateId = 100,
                                                                                                                                         RateType = new RateType{ Name = "Client" },
                                                                                                                                         RateAmount = 8.6m,
                                                                                                                                         Total = 43m
                                                                                                                                     },
                                                                                                                                  new RateViewModel
                                                                                                                                      {
                                                                                                                                          RateId = 200,
                                                                                                                                          RateType = new RateType{ Name = "Vendor" },
                                                                                                                                          RateAmount = 5.5m,
                                                                                                                                          Total = 27.5m
                                                                                                                                      }
                                                                                                                             },
                                                                                                                EntryType = EntryTypeEnum.Amount,
                                                                                                                Amount = 5m
                                                                                                             }
                                                                                                     }
                                                                               },
                                                                               new WorkdayViewModel
                                                                               {
                                                                                   WorkDate = new DateTime(2015, 05, 09),
                                                                                   TimeEntries = new List<TimeEntryViewModel>
                                                                                                     {
                                                                                                         new TimeEntryViewModel
                                                                                                             {
                                                                                                                 TimeEntryId = 130,
                                                                                                                 TimeEntryDate = new DateTime(2015, 05, 09),
                                                                                                                 TimeEntryKey = new TimesheetEntrySummaryLineKey
                                                                                                              {
                                                                                                                  EngagementId=5000,
                                                                                                                  BillingRuleId = 111,
                                                                                                                  CostCenterId = 111,
                                                                                                                  GeneralLedgerId = 111,
                                                                                                                  ProjectId = 111
                                                                                                              },
                                                                                                                 EngagementName = "Farm Hand: Peach Picker 3",
                                                                                                                 ProjectName = "Summer 2015 Season",
                                                                                                                 CostCenterName = "AAA222",
                                                                                                                 GeneralLedgerName = "BBB222",
                                                                                                                 BillingRule = "Standard Time",
                                                                                                                 Rates = new List<RateViewModel>
                                                                                                                             {
                                                                                                                                 new RateViewModel
                                                                                                                                     {
                                                                                                                                         RateId = 100,
                                                                                                                                         RateType = new RateType{ Name = "Client" },
                                                                                                                                         RateAmount = 8.6m,
                                                                                                                                         Total = 80.6m
                                                                                                                                     },
                                                                                                                                  new RateViewModel
                                                                                                                                      {
                                                                                                                                          RateId = 200,
                                                                                                                                          RateType = new RateType{ Name = "Vendor" },
                                                                                                                                          RateAmount = 5.5m,
                                                                                                                                          Total = 50.5m
                                                                                                                                      }
                                                                                                                             },
                                                                                                                             StartTime = new DateTime(2015,5,9,10,0,0,0),
                                                                                                                EndTime = new DateTime(2015,5,9,14,0,0,0),

                                                                                                                EntryType = EntryTypeEnum.Amount,
                                                                                                                Amount = 4m
                                                                                                             },
                                                                                                             new TimeEntryViewModel
                                                                                                             {
                                                                                                                 TimeEntryId = 130,
                                                                                                                 TimeEntryDate = new DateTime(2015, 05, 09),
                                                                                                                 TimeEntryKey = new TimesheetEntrySummaryLineKey
                                                                                                              {
                                                                                                                  EngagementId=5000,
                                                                                                                  BillingRuleId = 111,
                                                                                                                  CostCenterId = 111,
                                                                                                                  GeneralLedgerId = 111,
                                                                                                                  ProjectId = 111
                                                                                                              },
                                                                                                                 EngagementName = "Farm Hand: Peach Picker 3",
                                                                                                                 ProjectName = "Summer 2015 Season",
                                                                                                                 CostCenterName = "AAA222",
                                                                                                                 GeneralLedgerName = "BBB222",
                                                                                                                 BillingRule = "Standard Time",
                                                                                                                 Rates = new List<RateViewModel>
                                                                                                                             {
                                                                                                                                 new RateViewModel
                                                                                                                                     {
                                                                                                                                         RateId = 100,
                                                                                                                                         RateType = new RateType{ Name = "Client" },
                                                                                                                                         RateAmount = 8.6m,
                                                                                                                                         Total = 80.6m
                                                                                                                                     },
                                                                                                                                  new RateViewModel
                                                                                                                                      {
                                                                                                                                          RateId = 200,
                                                                                                                                          RateType = new RateType{ Name = "Vendor" },
                                                                                                                                          RateAmount = 5.5m,
                                                                                                                                          Total = 50.5m
                                                                                                                                      }
                                                                                                                             },
                                                                                                                EntryType = EntryTypeEnum.Amount,
                                                                                                                StartTime = new DateTime(2015,5,9,15,0,0,0),
                                                                                                                EndTime = new DateTime(2015,5,9,18,0,0,0),
                                                                                                                Amount = 3m
                                                                                                             },
                                                                                                             new TimeEntryViewModel
                                                                                                             {
                                                                                                                 TimeEntryId = 130,
                                                                                                                 TimeEntryDate = new DateTime(2015, 05, 09),
                                                                                                                 TimeEntryKey = new TimesheetEntrySummaryLineKey
                                                                                                              {
                                                                                                                  EngagementId=5000,
                                                                                                                  BillingRuleId = 222,
                                                                                                                  CostCenterId = 111,
                                                                                                                  GeneralLedgerId = 111,
                                                                                                                  ProjectId = 111
                                                                                                              },
                                                                                                                 EngagementName = "Farm Hand: Peach Picker 3",
                                                                                                                 ProjectName = "Summer 2015 Season",
                                                                                                                 CostCenterName = "AAA222",
                                                                                                                 GeneralLedgerName = "BBB222",
                                                                                                                 BillingRule = "Overtime",
                                                                                                                 Rates = new List<RateViewModel>
                                                                                                                             {
                                                                                                                                 new RateViewModel
                                                                                                                                     {
                                                                                                                                         RateId = 100,
                                                                                                                                         RateType = new RateType{ Name = "Client" },
                                                                                                                                         RateAmount = 10m,
                                                                                                                                         Total = 20m
                                                                                                                                     },
                                                                                                                                  new RateViewModel
                                                                                                                                      {
                                                                                                                                          RateId = 200,
                                                                                                                                          RateType = new RateType{ Name = "Vendor" },
                                                                                                                                          RateAmount = 8m,
                                                                                                                                          Total = 16m
                                                                                                                                      }
                                                                                                                             },
                                                                                                                EntryType = EntryTypeEnum.Amount,
                                                                                                                Amount = 2m
                                                                                                             },
                                                                                                             new TimeEntryViewModel
                                                                                                             {
                                                                                                                 TimeEntryId = 130,
                                                                                                                 TimeEntryDate = new DateTime(2015, 05, 09),
                                                                                                                 TimeEntryKey = new TimesheetEntrySummaryLineKey
                                                                                                              {
                                                                                                                  EngagementId=6000,
                                                                                                                  BillingRuleId = 2222,
                                                                                                                  CostCenterId = 111,
                                                                                                                  GeneralLedgerId = 111,
                                                                                                                  ProjectId = 111
                                                                                                              },
                                                                                                                 EngagementName = "Farm Hand: Peach Picker 3",
                                                                                                                 ProjectName = "Summer 2015 Season",
                                                                                                                 CostCenterName = "AAA22A",
                                                                                                                 GeneralLedgerName = "BBB2222",
                                                                                                                 BillingRule = "Bushels Picked",
                                                                                                                 Rates = new List<RateViewModel>
                                                                                                                             {
                                                                                                                                 new RateViewModel
                                                                                                                                     {
                                                                                                                                         RateId = 100,
                                                                                                                                         RateType = new RateType{ Name = "Client" },
                                                                                                                                         RateAmount = .5m,
                                                                                                                                         Total = 25m
                                                                                                                                     },
                                                                                                                                  new RateViewModel
                                                                                                                                      {
                                                                                                                                          RateId = 200,
                                                                                                                                          RateType = new RateType{ Name = "Vendor" },
                                                                                                                                          RateAmount = .75m,
                                                                                                                                          Total = 37.5m
                                                                                                                                      }
                                                                                                                             },
                                                                                                                EntryType = EntryTypeEnum.Amount,
                                                                                                                Amount = 50m
                                                                                                             }
                                                                                                     }
                                                                               }
                                                                       }

                                                     }
                                             };
        }
        public static WorkerTimesheetApproverViewModel CreateWeeklyTimesheet(DateTime periodEndDate, DayOfWeek weekStartDay)
        {
            int frequency = 7;
            var timesheet = new WorkerTimesheetApproverViewModel { CalendarDays = new List<DateTime>() };

            var weekStartDayNumber = (int)weekStartDay;
            var weekEndDay = weekStartDayNumber == 0 ? 6 : weekStartDayNumber - 1;
            var dayDiff = weekEndDay - (int)periodEndDate.DayOfWeek;

            periodEndDate = dayDiff > 0 ? periodEndDate.AddDays(dayDiff - 7) : periodEndDate.AddDays(dayDiff);

            timesheet.PeriodEndDate = periodEndDate;
            for (var day = periodEndDate.AddDays(1 - frequency); day <= periodEndDate; day = day.AddDays(1))
            {
                timesheet.CalendarDays.Add(day);
            }
            return timesheet;
        }