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)); }
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()); }