public void IncrementWeeks(int weekCount)
        {
            var startDate = CalendarStartDate.AddWeeks(weekCount);
            var endDate   = startDate.AddWeeks(TimesheetsCalendarViewModel.WeekCount).AddDays(-1);

            var maxEndDate = DateTime.Today.ToNextDay(DayOfWeek.Sunday);

            if (endDate <= maxEndDate)
            {
                CalendarStartDate = startDate;
                SearchTimesheets();
            }
        }
 public void Refresh()
 {
     RefreshDateRange(CalendarStartDate, CalendarStartDate.AddWeeks(TimesheetsCalendarViewModel.WeekCount), onComplete: () =>
     {
         if (TimesheetDayViewModel != null)
         {
             TimesheetDayViewModel.RefreshData();
         }
         else
         {
             CalendarSelectedDate = DateTime.Today;
         }
     });
 }
        public void SearchTimesheets()
        {
            var predicates = new List <Func <TimesheetSearchResult, bool> >();

            if (!string.IsNullOrEmpty(FilterTimesheets))
            {
                var data = FilterTimesheets.ToLower().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                for (var i = 0; i < data.Length; i++)
                {
                    var dataItem = data[i];
                    predicates.Add(x => (x.TaskNumber ?? string.Empty).ToLower().Contains(dataItem) || (x.Description ?? string.Empty).ToLower().Contains(dataItem));
                }
            }

            if (CalendarMode)
            {
                var startDate = CalendarStartDate;
                var endDate   = CalendarEndDate;

                var timesheets = _data.Where(x => x.StartTime.Date >= startDate && x.EndTime.Date <= endDate).Where(predicates).ToList();

                var weeks = new List <TimesheetsOverviewWeekViewModel>();

                for (var i = 0; i < TimesheetsCalendarViewModel.WeekCount; i++)
                {
                    weeks.Add(new TimesheetsOverviewWeekViewModel(TimesheetsCalendarViewModel, CalendarStartDate.AddWeeks(i), timesheets, _sessionSwitches));
                }

                TimesheetsCalendarViewModel.TimesheetsWeeks = weeks;

                if (TimesheetsDumpViewModel != null)
                {
                    TimesheetsDumpViewModel.SetCurrentWeek(weeks.Last());
                }
            }
            else
            {
                TimesheetsFiltered = _data.Where(predicates).OrderByDescending(x => x.StartTime.Date).ThenBy(x => x.StartTime).ToList();
            }
        }