public async Task<PagedResult<SeasonSummaryEntryDto>> GetSeasonRolesSummary(Query<SeasonSummarySearchCriteria> query)
		{
			var seasonPredicate = seasonSearchCriteriaService.BuildExpression(mapper.Map<SeasonSearchCriteria>(query.SearchCriteria));

			var foundSeason = await seasonRepository.GetAsync(seasonPredicate);

			if (foundSeason != null)
			{
				query.SearchCriteria.Id = foundSeason.Id;
				var animePredicate = animeSearchCriteriaService.BuildExpression(mapper.Map<AnimeSearchCriteria>(query.SearchCriteria));

				var animeInSeason = await animeRepository.GetAllAsync(animePredicate);

				if (animeInSeason.Count > 0)
				{
					query.SearchCriteria.AnimeId = animeInSeason.Select(x => x.MalId).ToList();

					var rolePredicate = roleSearchCriteriaService.BuildExpression(mapper.Map<RoleSearchCriteria>(query.SearchCriteria));

					IReadOnlyCollection<Role> allRolesInSeason = await roleRepository.GetAllAsync(rolePredicate, roleRepository.IncludeExpression);

					return mapper.Map<PagedResult<SeasonSummaryEntryDto>>(GroupRoles(allRolesInSeason, query));
				}
			}

			return null;
		}
Exemple #2
0
        public async Task <PagedResult <AnimeSearchEntryDto> > GetAsync(Query <AnimeSearchCriteria> query)
        {
            var expression = animeSearchCriteriaService.BuildExpression(query.SearchCriteria);

            var entities = await animeRepository.GetOrderedPageAsync(expression, query.SortExpression, query.Page, query.PageSize);

            return(mapper.Map <PagedResult <AnimeSearchEntryDto> >(entities));
        }
Exemple #3
0
        public async Task <PagedResult <AnimeSearchEntryDto> > HandleAsync(SearchAnimeQuery query)
        {
            var expression = _animeSearchCriteriaService.BuildExpression(query);

            var entities = await _animeRepository.GetOrderedPageByPopularityAsync(expression);

            return(entities.Map <Anime, AnimeSearchEntryDto>(entities.Results.Select(x => x.ToAnimeSearchEntryDto())));
        }