namespace BuildingBlocks.Core.Pagination; public record PageList(IReadOnlyList Items, int PageNumber, int PageSize, int TotalCount) : IPageList where T : class { public int CurrentPageSize => Items.Count; public int CurrentStartIndex => TotalCount == 0 ? 0 : ((PageNumber - 1) * PageSize) + 1; public int CurrentEndIndex => TotalCount == 0 ? 0 : CurrentStartIndex + CurrentPageSize - 1; public int TotalPages => (int)Math.Ceiling(TotalCount / (double)PageSize); public bool HasPrevious => PageNumber > 1; public bool HasNext => PageNumber < TotalPages; public static PageList Empty => new(Enumerable.Empty().ToList(), 0, 0, 0); public static PageList Create(IReadOnlyList items, int pageNumber, int pageSize, int totalItems) { return new PageList(items, pageNumber, pageSize, totalItems); } }