public async Task <IActionResult> Get(int pageSize = 10, int pageIndex = 0) { var result = await _bookService.GetBooksAsync(); var totalItems = result.Count(); var itemsOnPage = result .OrderBy(c => c.Name) .Skip(pageSize * pageIndex) .Take(pageSize); var model = new PaginatedBooksResponseModel <BookResponse>( pageIndex, pageSize, totalItems, itemsOnPage); return(Ok(model)); }
public async Task <IActionResult> Get([FromQuery] int pageSize = 10, [FromQuery] int pageIndex = 0) { var result = await _artistService.GetAuthorsAsync(); var totalBooks = result.ToList().Count; var itemsOnPage = result .OrderBy(c => c.AuthorName) .Skip(pageSize * pageIndex) .Take(pageSize); var model = new PaginatedBooksResponseModel <AuthorResponse>( pageIndex, pageSize, totalBooks, itemsOnPage); return(Ok(model)); }
public async Task <IActionResult> Get([FromQuery] int pageSize = 10, [FromQuery] int pageIndex = 0) { var result = await _genreService.GetGenreAsync(); var totalItems = result.ToList().Count; var itemsOnPage = result .OrderBy(c => c.GenreDescription) .Skip(pageSize * pageIndex) .Take(pageSize); var model = new PaginatedBooksResponseModel <GenreResponse>( pageIndex, pageSize, totalItems, itemsOnPage); return(Ok(model)); }