Ejemplo n.º 1
0
        private IEnumerable <LeaguesSeasonsIdDto> FilterByLeaguesId(LeaguesSeasonsIdQuery request)
        {
            var seasonsRepo = _uow.GetReadOnlyRepository <Season>();

            List <Season> seasons;

            if (request.LeaguesSeasonsIdQueryType == LeaguesSeasonsIdQueryType.All)
            {
                seasons = seasonsRepo.GetList( //todo:: paged queries
                    s => request.LeaguesId.Contains(s.LeagueId)).Items.ToList();
            }
            else
            {
                seasons = seasonsRepo.GetList(
                    s => request.LeaguesId.Contains(s.LeagueId) &&
                    s.Finish >= DateTime.UtcNow).Items.ToList();
            }

            IEnumerable <LeaguesSeasonsIdDto> dtos = seasons.Select(s => new LeaguesSeasonsIdDto()
            {
                SeasonId = s.Id,
                LeagueId = s.LeagueId
            });

            return(dtos);
        }
Ejemplo n.º 2
0
        public async Task <IEnumerable <LeaguesSeasonsIdDto> > Handle(LeaguesSeasonsIdQuery request, CancellationToken cancellationToken)
        {
            if (request.SeasonsId == null && request.LeaguesId == null)
            {
                return(null);
            }

            if (request.SeasonsId != null &&
                request.SeasonsId.Length != 0)
            {
                return(FilterBySeasonsId(request.SeasonsId));
            }

            return(FilterByLeaguesId(request));
        }