public static PagedList <T> BuildUsingPagedList <TSource>(PagedList <TSource> source) { var result = new PagedList <T> { _paginationStats = PaginationStats.FromPaginationStats(source._paginationStats) }; return(result); }
public static PaginationStats SinglePage(int count) { var result = new PaginationStats(); result._totalNumberOfItems = result._pageSize = count; result._pageNumber = result._totalNumberOfPages = result._firstItemIndex = 1; return(result); }
public static PagedList <T> BuildUsingStartIndex(int totalNumberOfItems, int pageSize, int startIndex) { var result = new PagedList <T> { _paginationStats = PaginationStats.FromStartIndex(totalNumberOfItems, pageSize, startIndex) }; return(result); }
public static PagedList <T> BuildUsingPageNumber(int totalNumberOfItems, int pageSize, int pageNumber) { var result = new PagedList <T> { _paginationStats = PaginationStats.FromPageNumber(totalNumberOfItems, pageSize, pageNumber) }; return(result); }
public static PagedList <T> BuildFromCompleteList(List <T> allItems) { var result = new PagedList <T> { PageItems = allItems, _paginationStats = PaginationStats.SinglePage(allItems.Count) }; return(result); }
public static PaginationStats FromPaginationStats(PaginationStats source) { var result = new PaginationStats { _totalNumberOfItems = source._totalNumberOfItems, _pageSize = source._pageSize, _totalNumberOfPages = source._totalNumberOfPages, _firstItemIndex = source._firstItemIndex, _pageNumber = source._pageNumber }; return(result); }
public static PaginationStats FromStartIndex(int totalNumberOfItems, int pageSize, int startIndex) { var result = new PaginationStats { _totalNumberOfItems = totalNumberOfItems, _pageSize = pageSize, _totalNumberOfPages = (totalNumberOfItems + pageSize - 1) / pageSize, _firstItemIndex = Math.Max(Math.Min(startIndex, totalNumberOfItems), 1), _pageNumber = (startIndex + pageSize - 2) / pageSize + 1 }; return(result); }
public static PaginationStats FromPageNumber(int totalNumberOfItems, int pageSize, int pageNumber) { var result = new PaginationStats { _totalNumberOfItems = totalNumberOfItems, _pageSize = pageSize, _totalNumberOfPages = (totalNumberOfItems + pageSize - 1) / pageSize }; result._pageNumber = Math.Max(Math.Min(pageNumber, result._totalNumberOfPages), 1); result._firstItemIndex = (result._pageNumber - 1) * result._pageSize + 1; return(result); }
public PagedList(List <T> allItems) { PageItems = allItems; _paginationStats = PaginationStats.SinglePage(allItems.Count); }
public PagedList(int totalNumberOfItems, int pageSize, int pageNumber) { _paginationStats = PaginationStats.FromPageNumber(totalNumberOfItems, pageSize, pageNumber); }