mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-08-01 09:48:37 +00:00
Improve pagination of the level listing
This commit is contained in:
parent
2874022f5e
commit
36c108e799
2 changed files with 14 additions and 1 deletions
|
@ -31,4 +31,8 @@
|
|||
{
|
||||
<a href="/slots/@(Model.PageNumber - 1)">Previous Page</a>
|
||||
}
|
||||
<a href="/slots/@(Model.PageNumber + 1)">Next Page</a>
|
||||
@(Model.PageNumber + 1) / @(Model.PageAmount)
|
||||
@if (Model.PageNumber < Model.PageAmount - 1)
|
||||
{
|
||||
<a href="/slots/@(Model.PageNumber + 1)">Next Page</a>
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
@ -17,6 +18,8 @@ namespace LBPUnion.ProjectLighthouse.Pages
|
|||
public int PageNumber;
|
||||
|
||||
public int SlotCount;
|
||||
|
||||
public int PageAmount;
|
||||
|
||||
public List<Slot> Slots;
|
||||
public SlotsPage([NotNull] Database database) : base(database)
|
||||
|
@ -27,7 +30,13 @@ namespace LBPUnion.ProjectLighthouse.Pages
|
|||
this.SlotCount = await StatisticsHelper.SlotCount();
|
||||
|
||||
this.PageNumber = pageNumber;
|
||||
this.PageAmount = (int)Math.Ceiling((double)this.SlotCount / ServerStatics.PageSize);
|
||||
|
||||
if (this.PageNumber < 0 || this.PageNumber >= this.PageAmount)
|
||||
{
|
||||
return this.Redirect($"/slots/{Math.Clamp(this.PageNumber, 0, this.PageAmount - 1)}");
|
||||
}
|
||||
|
||||
this.Slots = await this.Database.Slots.Include
|
||||
(p => p.Creator)
|
||||
.OrderByDescending(p => p.FirstUploaded)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue