diff --git a/ProjectLighthouse/Pages/SlotsPage.cshtml b/ProjectLighthouse/Pages/SlotsPage.cshtml index ef76e3aa..89ba207a 100644 --- a/ProjectLighthouse/Pages/SlotsPage.cshtml +++ b/ProjectLighthouse/Pages/SlotsPage.cshtml @@ -31,4 +31,8 @@ { Previous Page } -Next Page \ No newline at end of file +@(Model.PageNumber + 1) / @(Model.PageAmount) +@if (Model.PageNumber < Model.PageAmount - 1) +{ + Next Page +} diff --git a/ProjectLighthouse/Pages/SlotsPage.cshtml.cs b/ProjectLighthouse/Pages/SlotsPage.cshtml.cs index cc1388fb..12c7432e 100644 --- a/ProjectLighthouse/Pages/SlotsPage.cshtml.cs +++ b/ProjectLighthouse/Pages/SlotsPage.cshtml.cs @@ -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 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)