protected void LoadSpecialDatesAsync(DateTime from, DateTime to) { IsBusy = true; Device.BeginInvokeOnMainThread(async() => { try { if (this.IsInternetAndCloseModal()) { _currentTimesheet = await _timesheetModule.TimesheetService.GetTimesheetBeetweenDates(from, to); var specialDates = await _timesheetModule.CalendarService.GetSpecialDatesBeetweenDatesAsync(_currentTimesheet); specialDates.ForEach(x => SpecialDates.Add(x)); var now = _currentDayMonthYear; var minMonth = new DateTime(now.Year, now.Month, 1); var maxMonth = minMonth.AddMonths(1).AddDays(-1); var calculateActivities = _currentTimesheet.Activities.Where(x => x.Value.Date >= minMonth && x.Value.Date <= maxMonth); ImputedTotal = calculateActivities.Sum(x => x.Value.Imputed); DeviationTotal = calculateActivities.Sum(x => x.Value.Deviation); } IsBusy = false; } catch (Exception e) { IsBusy = false; BaseModule.DialogErrorCustomService.DialogErrorCommonTryAgain(); }finally { IsLoadCalendar = true; } }); }
protected void LoadSpecialDatesAsync(DateTime from, DateTime to) { IsBusy = true; Device.BeginInvokeOnMainThread(async() => { try { Dates.Clear(); _currentTimesheet = await _timesheetModule.TimesheetService.GetTimesheetBeetweenDates(from, to); var specialDates = await _timesheetModule.CalendarService.GetSpecialDatesBeetweenDatesAsync(_currentTimesheet); specialDates.ForEach(x => SpecialDates.Add(x)); IsBusy = false; } catch (Exception ex) { IsBusy = false; Debug.WriteLine($"[Booking] Error: {ex}"); await BaseModule.DialogService.ShowAlertAsync( "An error ocurred, try again", "Error", "Ok"); } }); }