public static async Task <ObservableCollection <Month> > Get() { if (historic != null) { return(historic); } PersonalInfoRespository repository = new PersonalInfoRespository(); PersonalInfo personalInfo = await repository.LoadAsync(); var ttRepository = new TTRepository(); var storedHistoricalChecks = await ttRepository.FindAllByUserNameAsync(personalInfo.login); int daysToCheck; if (DateTime.Now.Day > 20) { // do dia 21 ao 20 do próximo mês daysToCheck = DateTime.Now.Day - 20; } else { // do dia 21 do mês passado ao dia 20 do mês atual var day20 = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 20).AddMonths(-1); daysToCheck = (int)DateTime.Now.Subtract(day20).TotalDays; } var historicalChecks = new List <TTCheck>(storedHistoricalChecks); // Add empty checks to days without checks for (var i = 0; i < daysToCheck; i++) { var day = DateTime.Now.AddDays(-i); if (!day.IsWeekend() && !HasCheckInDay(storedHistoricalChecks, day)) { historicalChecks.Add(new TTCheck() { DateTime = day, UserName = String.Empty }); } } historic = getMonths(historicalChecks); return(historic); }
private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { if (!SecurityService.IsLogged) { GoToLoginPage(); } else { try { PersonalInfoRespository repository = new PersonalInfoRespository(); HubSectionProfile.DataContext = await repository.LoadAsync(); HubSectionHistoricalChecks.DataContext = await Historic.Historic.Get(); } catch { SecurityService.logoff(); GoToLoginPage(); } } }