File tree 1 file changed +12
-10
lines changed
src/JsonApiDotNetCore/Internal
1 file changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -11,28 +11,30 @@ public class PageManager
11
11
public int DefaultPageSize { get ; set ; }
12
12
public int CurrentPage { get ; set ; }
13
13
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 ) ) ;
15
15
16
16
public RootLinks GetPageLinks ( LinkBuilder linkBuilder )
17
- {
18
- if ( ! IsPaginated || ( CurrentPage == 1 && TotalPages <= 0 ) )
17
+ {
18
+ if ( ShouldIncludeLinksObject ( ) )
19
19
return null ;
20
-
20
+
21
21
var rootLinks = new RootLinks ( ) ;
22
22
23
- if ( CurrentPage > 1 )
23
+ if ( CurrentPage > 1 )
24
24
rootLinks . First = linkBuilder . GetPageLink ( 1 , PageSize ) ;
25
25
26
- if ( CurrentPage > 1 )
26
+ if ( CurrentPage > 1 )
27
27
rootLinks . Prev = linkBuilder . GetPageLink ( CurrentPage - 1 , PageSize ) ;
28
-
29
- if ( CurrentPage < TotalPages )
28
+
29
+ if ( CurrentPage < TotalPages )
30
30
rootLinks . Next = linkBuilder . GetPageLink ( CurrentPage + 1 , PageSize ) ;
31
-
32
- if ( TotalPages > 0 )
31
+
32
+ if ( TotalPages > 0 )
33
33
rootLinks . Last = linkBuilder . GetPageLink ( TotalPages , PageSize ) ;
34
34
35
35
return rootLinks ;
36
36
}
37
+
38
+ private bool ShouldIncludeLinksObject ( ) => ( ! IsPaginated || ( ( CurrentPage == 1 || CurrentPage == 0 ) && TotalPages <= 0 ) ) ;
37
39
}
38
40
}
You can’t perform that action at this time.
0 commit comments