Created
September 3, 2019 12:58
-
-
Save ntakouris/45260c79995aaa015a04ae5020df7d24 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 static PagedResponse<T> CreatePaginatedResponse<T>(IUriService uriService, PaginationFilter pagination, List<T> response) | |
{ | |
var nextPage = pagination.PageNumber >= 1 | |
? uriService.GetAllPostsUri(new PaginationQuery(pagination.PageNumber + 1, pagination.PageSize)).ToString() | |
: null; | |
var previousPage = pagination.PageNumber - 1 >= 1 | |
? uriService.GetAllPostsUri(new PaginationQuery(pagination.PageNumber - 1, pagination.PageSize)).ToString() | |
: null; | |
return new PagedResponse<T> | |
{ | |
Data = response, | |
PageNumber = pagination.PageNumber >= 1 ? pagination.PageNumber : (int?)null, | |
PageSize = pagination.PageSize >= 1 ? pagination.PageSize : (int?)null, | |
NextPage = response.Any() ? nextPage : null, | |
PreviousPage = previousPage | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment