37 lines
1.2 KiB
C#
37 lines
1.2 KiB
C#
namespace MyNewProjectName.Contracts.Common
|
|
{
|
|
// PagedList model to support pagination in API responses
|
|
public class PagedList<T>
|
|
{
|
|
// Items in the current page
|
|
public List<T> Items { get; set; } = new List<T>();
|
|
|
|
// Total count of items across all pages
|
|
public int TotalCount { get; set; }
|
|
|
|
// Current page number
|
|
public int PageNumber { get; set; }
|
|
|
|
// Page size (items per page)
|
|
public int PageSize { get; set; }
|
|
|
|
// Total number of pages
|
|
public int TotalPages => (int)Math.Ceiling(TotalCount / (double)PageSize);
|
|
|
|
// Flag indicating if there is a previous page
|
|
public bool HasPreviousPage => PageNumber > 1;
|
|
|
|
// Flag indicating if there is a next page
|
|
public bool HasNextPage => PageNumber < TotalPages;
|
|
public PagedList(List<T> items, int totalCount, int pageNumber, int pageSize)
|
|
{
|
|
Items = items;
|
|
TotalCount = totalCount;
|
|
PageNumber = pageNumber;
|
|
PageSize = pageSize;
|
|
}
|
|
|
|
// Default constructor
|
|
public PagedList() { }
|
|
}
|
|
} |