File tree Expand file tree Collapse file tree 1 file changed +12
-10
lines changed
src/JsonApiDotNetCore/Internal Expand file tree Collapse file tree 1 file changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -11,28 +11,30 @@ public class PageManager
1111 public int DefaultPageSize { get ; set ; }
1212 public int CurrentPage { get ; set ; }
1313 public bool IsPaginated => PageSize > 0 ;
14- public int TotalPages => ( TotalRecords == 0 ) ? - 1 : ( int ) Math . Ceiling ( decimal . Divide ( TotalRecords , PageSize ) ) ;
14+ public int TotalPages => ( TotalRecords == 0 ) ? - 1 : ( int ) Math . Ceiling ( decimal . Divide ( TotalRecords , PageSize ) ) ;
1515
1616 public RootLinks GetPageLinks ( LinkBuilder linkBuilder )
17- {
18- if ( ! IsPaginated || ( CurrentPage == 1 && TotalPages <= 0 ) )
17+ {
18+ if ( ShouldIncludeLinksObject ( ) )
1919 return null ;
20-
20+
2121 var rootLinks = new RootLinks ( ) ;
2222
23- if ( CurrentPage > 1 )
23+ if ( CurrentPage > 1 )
2424 rootLinks . First = linkBuilder . GetPageLink ( 1 , PageSize ) ;
2525
26- if ( CurrentPage > 1 )
26+ if ( CurrentPage > 1 )
2727 rootLinks . Prev = linkBuilder . GetPageLink ( CurrentPage - 1 , PageSize ) ;
28-
29- if ( CurrentPage < TotalPages )
28+
29+ if ( CurrentPage < TotalPages )
3030 rootLinks . Next = linkBuilder . GetPageLink ( CurrentPage + 1 , PageSize ) ;
31-
32- if ( TotalPages > 0 )
31+
32+ if ( TotalPages > 0 )
3333 rootLinks . Last = linkBuilder . GetPageLink ( TotalPages , PageSize ) ;
3434
3535 return rootLinks ;
3636 }
37+
38+ private bool ShouldIncludeLinksObject ( ) => ( ! IsPaginated || ( ( CurrentPage == 1 || CurrentPage == 0 ) && TotalPages <= 0 ) ) ;
3739 }
3840}
You can’t perform that action at this time.
0 commit comments