mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-28 07:58:40 +00:00
Add better pagination to photos page
This commit is contained in:
parent
2fef9d9449
commit
ba91a9994f
2 changed files with 14 additions and 1 deletions
|
@ -20,4 +20,8 @@
|
|||
{
|
||||
<a href="/photos/@(Model.PageNumber - 1)">Previous Page</a>
|
||||
}
|
||||
<a href="/photos/@(Model.PageNumber + 1)">Next Page</a>
|
||||
@(Model.PageNumber + 1) / @(Model.PageAmount)
|
||||
@if (Model.PageNumber < Model.PageAmount - 1)
|
||||
{
|
||||
<a href="/photos/@(Model.PageNumber + 1)">Next Page</a>
|
||||
}
|
|
@ -1,3 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
@ -18,6 +19,8 @@ namespace LBPUnion.ProjectLighthouse.Pages
|
|||
|
||||
public int PhotoCount;
|
||||
|
||||
public int PageAmount;
|
||||
|
||||
public List<Photo> Photos;
|
||||
public PhotosPage([NotNull] Database database) : base(database)
|
||||
{}
|
||||
|
@ -27,6 +30,12 @@ namespace LBPUnion.ProjectLighthouse.Pages
|
|||
this.PhotoCount = await StatisticsHelper.PhotoCount();
|
||||
|
||||
this.PageNumber = pageNumber;
|
||||
this.PageAmount = (int)Math.Ceiling((double)this.PhotoCount / ServerStatics.PageSize);
|
||||
|
||||
if (this.PageNumber < 0 || this.PageNumber >= this.PageAmount)
|
||||
{
|
||||
return this.Redirect($"/photos/{Math.Clamp(this.PageNumber, 0, this.PageAmount - 1)}");
|
||||
}
|
||||
|
||||
this.Photos = await this.Database.Photos.Include
|
||||
(p => p.Creator)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue