private async Task calendarDayTapped(ReportsCalendarDayViewModel tappedDay) { if (startOfSelection == null) { var date = tappedDay.DateTimeOffset; var dateRange = ReportsDateRangeParameter .WithDates(date, date) .WithSource(ReportsSource.Calendar); startOfSelection = tappedDay; highlightDateRange(dateRange); } else { var startDate = startOfSelection.DateTimeOffset; var endDate = tappedDay.DateTimeOffset; if (System.Math.Abs((endDate - startDate).Days) > 365) { await dialogService.Alert( Resources.ReportTooLongTitle, Resources.ReportTooLongDescription, Resources.Ok ); } else { var dateRange = ReportsDateRangeParameter .WithDates(startDate, endDate) .WithSource(ReportsSource.Calendar); startOfSelection = null; changeDateRange(dateRange); } } }
private void changeDateRange(ReportsDateRangeParameter newDateRange) { startOfSelection = null; highlightDateRange(newDateRange); selectedDateRangeSubject.OnNext(newDateRange); }
private static bool ensureDateRangeIsCorrect( ReportsDateRangeParameter dateRange, ReportsCalendarDayViewModel expectedStart, ReportsCalendarDayViewModel expectedEnd) => dateRange.StartDate.Year == expectedStart.CalendarMonth.Year && dateRange.StartDate.Month == expectedStart.CalendarMonth.Month && dateRange.StartDate.Day == expectedStart.Day && dateRange.EndDate.Year == expectedEnd.CalendarMonth.Year && dateRange.EndDate.Month == expectedEnd.CalendarMonth.Month && dateRange.EndDate.Day == expectedEnd.Day;
private void calendarDayTapped(ReportsCalendarDayViewModel tappedDay) { if (startOfSelection == null) { var date = tappedDay.DateTimeOffset; var dateRange = ReportsDateRangeParameter .WithDates(date, date) .WithSource(ReportsSource.Calendar); startOfSelection = tappedDay; highlightDateRange(dateRange); } else { var startDate = startOfSelection.DateTimeOffset; var endDate = tappedDay.DateTimeOffset; var dateRange = ReportsDateRangeParameter .WithDates(startDate, endDate) .WithSource(ReportsSource.Calendar); startOfSelection = null; changeDateRange(dateRange); } }