public static GetCurrentChallengesResponse Select(GetCurrentChallengesResponse challenges) { var response = new GetCurrentChallengesResponse(); response.Challenges = challenges.Challenges.OrderByDescending(challenge => challenge.StartDate).Where(challenge => challenge.StartDate <DateTime.Now && challenge.EndDate> DateTime.Now).ToList(); return(response); }
private async Task GetParametersForChallenge() { var user = new User(); var currentSeasonReponse = new SeasonResponse(); var currentChallenges = new GetCurrentChallengesResponse(); var myTrophies = new GetThophiesByUserIdResponse(); user = await CacheAccess.GetSecure <User>(CacheKeys.USER_KEY); try { currentSeasonReponse = await _seasonAppService.CurrentSeason(); } catch {} await CheckRegisterChallengeCompleted(myTrophies.Trophies, user.UsuarioId.ToString(), currentChallenges.Challenges, currentSeasonReponse.Entity); }
private async void GoToCurrentChallengesPage() { var parameters = new NavigationParameters(); CanExecuteInitial(); await NavigationHelper.ShowLoading(); var season = new SeasonResponse(); bool isSuccess = true; var challenges = new GetCurrentChallengesResponse(); try { season = await _seasonAppService.CurrentSeason(); challenges = await _challengesAppService.GetCurrentChallenges(season.Entity.TemporadaId.ToString()); } catch { UserDialogs.Instance.Toast("Não foi possível obter os desafios, verifique sua conexâo", new TimeSpan(0, 0, 3)); isSuccess = false; } finally { challenges = SelectActualChallenges.Select(challenges); if (isSuccess && challenges.Challenges.Count > 0) { parameters.Add(NavigationKeyParameters.CurrentChallenges, challenges.Challenges); parameters.Add(NavigationKeyParameters.CurrentSeason, season.Entity); await _navigationService.NavigateAsync(NavigationSettings.CurrentChallenges, parameters); } else { UserDialogs.Instance.Toast("Não possuimos desafios ativos no momento!", new TimeSpan(0, 0, 3)); } } await NavigationHelper.PopLoading(); CanExecuteEnd(); }