mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-04-19 11:04:51 +00:00
Fix pagination for banned users in the mod panel (#1043)
This commit is contained in:
parent
376e1464a2
commit
a528c65445
1 changed files with 11 additions and 7 deletions
|
@ -21,21 +21,25 @@ public class BannedUsersPage : BaseLayout
|
|||
|
||||
public int UserCount;
|
||||
|
||||
public async Task<IActionResult> OnGet([FromRoute] int pageNumber, [FromQuery] string? name)
|
||||
public async Task<IActionResult> OnGet([FromRoute] int pageNumber)
|
||||
{
|
||||
WebTokenEntity? token = this.Database.WebTokenFromRequest(this.Request);
|
||||
if (token == null) return this.Redirect("/login");
|
||||
|
||||
this.Users = await this.Database.Users
|
||||
.Where(u => u.PermissionLevel < 0)
|
||||
this.UserCount = await this.Database.Users.CountAsync(u => u.PermissionLevel < 0);
|
||||
|
||||
this.PageNumber = pageNumber;
|
||||
this.PageAmount = Math.Max(1, (int)Math.Ceiling((double)this.UserCount / ServerStatics.PageSize));
|
||||
|
||||
if (this.PageNumber < 0 || this.PageNumber >= this.PageAmount)
|
||||
return this.Redirect($"/moderation/bannedUsers/{Math.Clamp(this.PageNumber, 0, this.PageAmount - 1)}");
|
||||
|
||||
this.Users = await this.Database.Users.Where(u => u.PermissionLevel < 0)
|
||||
.OrderByDescending(u => u.UserId)
|
||||
.Skip(pageNumber * ServerStatics.PageSize)
|
||||
.Take(ServerStatics.PageSize)
|
||||
.ToListAsync();
|
||||
|
||||
this.UserCount = await this.Database.Users.CountAsync(u => u.PermissionLevel < 0);
|
||||
|
||||
this.PageAmount = Math.Max(1, (int)Math.Ceiling((double)this.UserCount / ServerStatics.PageSize));
|
||||
|
||||
return this.Page();
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue