shopping-assistant-api/ShoppingAssistantApi.Application/Paging/PagedList.cs
2023-09-22 23:02:20 +03:00

30 lines
746 B
C#

namespace ShoppingAssistantApi.Application.Paging;
public class PagedList<T>
{
public IEnumerable<T> Items { get; set; }
public int PageNumber { get; set; }
public int PageSize { get; set; }
public int TotalPages { get; set; }
public int TotalItems { get; set; }
public bool HasPreviousPage => PageNumber > 1;
public bool HasNextPage => PageNumber < TotalPages;
public PagedList() { }
public PagedList(IEnumerable<T> items, int pageNumber, int pageSize, int totalItems)
{
this.PageNumber = pageNumber;
this.PageSize = pageSize;
this.TotalItems = totalItems;
this.TotalPages = (int)Math.Ceiling(totalItems / (double)pageSize);
this.Items = items;
}
}