http-api/src/Application/Common/Models/PaginatedList.cs
2025-04-29 23:51:19 +03:00

24 lines
632 B
C#

namespace cuqmbr.TravelGuide.Application.Common.Models;
public class PaginatedList<T>
{
public IReadOnlyCollection<T> Items { get; }
public int PageNumber { get; }
public int TotalPages { get; }
public int TotalCount { get; }
public PaginatedList(
IReadOnlyCollection<T> items, int count,
int pageNumber, int pageSize)
{
PageNumber = pageNumber;
TotalPages = (int) Math.Ceiling(count / (double) pageSize);
TotalCount = count;
Items = items;
}
public bool HasPreviousPage => PageNumber > 1;
public bool HasNextPage => PageNumber < TotalPages;
}