public async Task <PagedResultDto <AuthorDto> > GetListAsync(GetAuthorListDto input) { return(await _cacheService.GetListAsync(AuthorCacheConsts.CacheKey.Key_GetList.FormatWith(input.SkipCount, input.MaxResultCount), async() => { if (string.IsNullOrWhiteSpace(input.Sorting)) { input.Sorting = nameof(Author.Name); } var authors = await _authorRepository.GetListAsync( input.SkipCount, input.MaxResultCount, input.Sorting, input.Filter ); var totalCount = await AsyncExecuter.CountAsync( _authorRepository.WhereIf( !string.IsNullOrWhiteSpace(input.Filter), author => author.Name.Contains(input.Filter) ) ); return new PagedResultDto <AuthorDto>( totalCount, ObjectMapper.Map <List <Author>, List <AuthorDto> >(authors) ); })); }
public async Task <PagedResultDto <AuthorDto> > GetListAsync(GetAuthorListDto input) { if (input.Sorting.IsNullOrWhiteSpace()) { input.Sorting = nameof(Author.Name); } var authors = await _authorRepository.GetListAsync( input.SkipCount, input.MaxResultCount, input.Sorting, input.Filter ); var totalCount = await AsyncExecuter.CountAsync( _authorRepository.WhereIf( !input.Filter.IsNullOrWhiteSpace(), author => author.Name.Contains(input.Filter) ) ); return(new PagedResultDto <AuthorDto>( totalCount, ObjectMapper.Map <List <Author>, List <AuthorDto> >(authors) )); }