public async Task <PagedResult <SeasonSummaryEntryDto> > HandleAsync(GetSeasonSummariesQuery query) { var seasonPredicate = _seasonSearchCriteriaService.BuildExpression(query); var foundSeason = await _seasonRepository.GetAsync(seasonPredicate); if (foundSeason != null) { var animeTypeId = query.TVSeriesOnly ? AnimeTypeId.TV : AnimeTypeId.AllTypes; var animeInSeason = await _animeRepository.GetAllBySeasonAndTypeAsync(foundSeason.Id, animeTypeId); if (animeInSeason.Any()) { var animeInSeasonIds = animeInSeason.Select(x => x.Id).ToList(); IReadOnlyCollection <AnimeRole> allRolesInSeason = await _seasonRoleRepository.GetAllRolesInSeason( animeInSeasonIds, query.MainRolesOnly ); var groupedRoles = GroupRoles(allRolesInSeason, query); var mappedRoles = groupedRoles.Map <SeasonSummaryEntry, SeasonSummaryEntryDto>(groupedRoles.Results.Select(x => x.ToSeasonSummaryEntryDto())); return(mappedRoles); } } return(null); }