private ChartingViewModel GetNext() { DateTime newStartDate; DateTime newFinishDate; if (IntervalType == DayConstant) { newStartDate = StartDay.AddDays(1); newFinishDate = FinishDay.AddDays(1); } else if (IntervalType == WeekConstant) { newStartDate = StartDay.AddDays(7).FirstDayOfWeek(); newFinishDate = FinishDay.AddDays(7).LastDayOfWeek(); } else { var previousMonth = StartDay.AddMonths(1); newStartDate = new DateTime(previousMonth.Year, previousMonth.Month, 1); newFinishDate = StartDay.AddMonths(1).AddDays(-1); } // start date can be future date if (newStartDate < DateTime.Now) { StartDay = newStartDate; FinishDay = newFinishDate; } return(new ChartingViewModel(AppService.GetStatisticData(StartDay, FinishDay), StartDay, FinishDay)); }
private ChartingViewModel AddPrevious() { if (IntervalType == DayConstant) { StartDay = StartDay.AddDays(-1); FinishDay = FinishDay.AddDays(-1); } else if (IntervalType == WeekConstant) { StartDay = StartDay.AddDays(-7).FirstDayOfWeek(); FinishDay = FinishDay.AddDays(-7).LastDayOfWeek(); } else { var previousMonth = StartDay.AddMonths(-1); StartDay = new DateTime(previousMonth.Year, previousMonth.Month, 1); FinishDay = StartDay.AddMonths(1).AddDays(-1); } return(new ChartingViewModel(AppService.GetStatisticData(StartDay, FinishDay), StartDay, FinishDay)); }