Ejemplo n.º 1
0
        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)
                       ));
        }
Ejemplo n.º 2
0
        public async Task <List <AuthorDto> > GetListAuthorAsync(GetAuthorListDto input)
        {
            if (input.Sorting.IsNullOrWhiteSpace())
            {
                input.Sorting = nameof(Author.Name);
            }
            var data = await _authorRepository.GetListAsync();

            return(ObjectMapper.Map <List <Author>, List <AuthorDto> >(data));
        }