Exemple #1
0
        private async Task <IPaginate <Tour> > FilterByPlayerIdAndIncomingStatus(
            ToursQuery request,
            IRepositoryReadOnly <Tour> toursRepo)
        {
            var leaguesId = await _leaguesService.GetPlayerJoinedLeagues(request.PlayerId);

            var actualSeasons = await _seasonsService.GetLeaguesSeasonsId(
                leaguesId,
                Array.Empty <int>(),
                LeaguesSeasonsIdQueryType.Actual);

            var tours = new List <Tour>();

            foreach (var season in actualSeasons)
            {
                var tour = toursRepo.Single(
                    t => t.SeasonId == season.SeasonId,
                    q => q.OrderByDescending(t => t.Date));

                if (tour != null && !tour.IsRegistrationClosed())
                {
                    tours.Add(tour);
                }
            }

            return(tours.ToPaginate(0, tours.Count));
        }