Created
September 3, 2019 12:56
-
-
Save ntakouris/011276beeedcba7fbfb07fd2a6e980cc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async Task<IActionResult> GetAll([FromQuery]PaginationQuery paginationQuery) | |
{ | |
var pagination = _mapper.Map<PaginationFilter>(paginationQuery); | |
var posts = await _postService.GetPostsAsync(pagination); | |
var postsResponse = _mapper.Map<List<PostResponse>>(posts); | |
if (pagination == null || pagination.PageNumber < 1 || pagination.PageSize < 1) | |
{ | |
return Ok(new PagedResponse<PostResponse>(postsResponse)); | |
} | |
var paginationResponse = PaginationHelpers.CreatePaginatedResponse(_uriService, pagination, postsResponse); | |
return Ok(paginationResponse); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment