/// <summary> /// Builds meta data to be used with PioneerPaginationTagHelper /// </summary> /// <param name="collectionSize">Total size of collection we are paginating</param> /// <param name="selectedPageNumber">Selected page number of pagination</param> /// <param name="itemsPerPage">How many items per paginated list</param> public PaginatedMetaModel GetMetaData(int collectionSize, int selectedPageNumber, int itemsPerPage) { var lastPage = _pageInCollectionService.GetLastPageInCollection(collectionSize, itemsPerPage); // Cover > out of range exceptions if (lastPage < selectedPageNumber) { selectedPageNumber = lastPage; } // Cover < out of range exceptions if (selectedPageNumber < 1) { selectedPageNumber = 1; } if (collectionSize == 0) { return(GetCollectionSizeZeroModel()); } _pages = _nodeService.BuildPageNodes(collectionSize, selectedPageNumber, itemsPerPage, NumberOfNodesInPaginatedList); return(new PaginatedMetaModel { PreviousPage = _previousPageService.BuildPreviousPage(_pages, collectionSize, selectedPageNumber, itemsPerPage), Pages = _pages, NextPage = _nextPageService.BuildNextPage( _pages, collectionSize, selectedPageNumber, itemsPerPage, NumberOfNodesInPaginatedList ) }); }