Untitled

mail@pastecode.io avatar
unknown
plain_text
17 days ago
564 B
3
Indexable
Never
public class PaginatedList<T>
{
    public IEnumerable<T> Items {get; }
    public int PageIndex {get; }
    public int TotalPages {get; }
    public int TotalCount {get; }

    public PaginatedList(IEnumerable<T> items, int pageIndex, int totalPages, int totalCount)
    {
        PageIndex = pageIndex;
        TotalPages = (int)Math.Ceiling(TotalCount / (double)totalPages);
        TotalCount = totalCount;
        Items = items;
    }

    public bool HasPreviousPage => PageIndex > 1;
    public bool HasNextPage => PageIndex < TotalPages;
}
Leave a Comment