auto.bus_api/SharedModels/QueryParameters/PagingMetadata.cs
2022-11-23 19:45:15 +02:00

20 lines
638 B
C#

namespace SharedModels.QueryParameters;
public class PagingMetadata<T>
{
public int CurrentPage { get; private set; }
public int TotalPages { get; private set; }
public int PageSize { get; private set; }
public int TotalCount { get; private set; }
public bool HasPrevious => CurrentPage > 1;
public bool HasNext => CurrentPage < TotalPages;
public PagingMetadata(IQueryable<T> source, int pageNumber, int pageSize)
{
TotalCount = source.Count();
PageSize = pageSize;
CurrentPage = pageNumber;
TotalPages = (int)Math.Ceiling(TotalCount / (double)pageSize);
}
}