auto.bus_api/SharedModels/QueryParameters/PagingMetadata.cs
2022-11-27 16:08:33 +02:00

20 lines
639 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(IEnumerable<T> source, int pageNumber, int pageSize)
{
TotalCount = source.Count();
PageSize = pageSize;
CurrentPage = pageNumber;
TotalPages = (int)Math.Ceiling(TotalCount / (double)pageSize);
}
}