Exemplo n.º 1
0
        public async Task <IActionResult> GetAuthors([FromQuery] AuthorsResourceParamenters authorsResourceParamenters)
        {
            var authorsFromRepo = await _libraryRepository.GetAuthors(authorsResourceParamenters);

            var authors = AutoMapper.Mapper.Map <IEnumerable <AuthorDto> >(authorsFromRepo);

            return(Ok(authors));
        }
Exemplo n.º 2
0
 public async Task <IEnumerable <Author> > GetAuthors(AuthorsResourceParamenters authorsResourceParamenters)
 {
     return(await _context.Authors
            .OrderBy(a => a.FirstName)
            .ThenBy(a => a.LastName)
            .Skip(authorsResourceParamenters.PageSize * (authorsResourceParamenters.PageNumber - 1))
            .Take(authorsResourceParamenters.PageSize)
            .ToListAsync());
 }