Repository navigation
Expand file tree
/
Copy pathPager.cs
More file actions
55 lines (44 loc) · 1.43 KB
/
Copy pathPager.cs
File metadata and controls
55 lines (44 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
namespace Blogifier.Shared
{
public class Pager
{
public Pager(int currentPage, int itemsPerPage = 0)
{
CurrentPage = currentPage;
ItemsPerPage = itemsPerPage;
if (ItemsPerPage == 0)
ItemsPerPage = 10;
Newer = CurrentPage - 1;
ShowNewer = CurrentPage > 1 ? true : false;
Older = currentPage + 1;
}
public void Configure(int total)
{
if (total == 0)
return;
if (ItemsPerPage == 0)
ItemsPerPage = 10;
Total = total;
var lastItem = CurrentPage * ItemsPerPage;
ShowOlder = total > lastItem ? true : false;
if (CurrentPage < 1 || lastItem > total + ItemsPerPage)
{
NotFound = true;
}
LastPage = (total % ItemsPerPage) == 0 ? total / ItemsPerPage : (total / ItemsPerPage) + 1;
if (LastPage == 0) LastPage = 1;
}
public int CurrentPage { get; set; } = 1;
public int ItemsPerPage { get; set; }
public int Total { get; set; }
public bool NotFound { get; set; }
public int Newer { get; set; }
public bool ShowNewer { get; set; }
public int Older { get; set; }
public bool ShowOlder { get; set; }
public string LinkToNewer { get; set; }
public string LinkToOlder { get; set; }
public string RouteValue { get; set; }
public int LastPage { get; set; } = 1;
}
}