mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-29 16:38:37 +00:00
Add pages to photos page
This commit is contained in:
parent
b137d3fc79
commit
2b5f91c1cd
3 changed files with 20 additions and 6 deletions
|
@ -28,7 +28,7 @@ namespace LBPUnion.ProjectLighthouse.Pages.Layouts
|
|||
public readonly List<PageNavigationItem> NavigationItems = new()
|
||||
{
|
||||
new PageNavigationItem("Home", "/", "home"),
|
||||
new PageNavigationItem("Photos", "/photos", "camera"),
|
||||
new PageNavigationItem("Photos", "/photos/0", "camera"),
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
@page "/photos"
|
||||
@page "/photos/{pageNumber:int}"
|
||||
@using LBPUnion.ProjectLighthouse.Types
|
||||
@model LBPUnion.ProjectLighthouse.Pages.PhotosPage
|
||||
|
||||
|
@ -12,7 +12,8 @@
|
|||
@foreach (Photo photo in Model.Photos)
|
||||
{
|
||||
<div class="ui segment">
|
||||
<img src="/gameAssets/@photo.LargeHash" style="width: 100%; height: auto; border-radius: .28571429rem;"><br>
|
||||
<img src="/gameAssets/@photo.LargeHash" style="width: 100%; height: auto; border-radius: .28571429rem;">
|
||||
<br>
|
||||
|
||||
<p>
|
||||
<i>
|
||||
|
@ -32,3 +33,11 @@
|
|||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (Model.PageNumber != 0)
|
||||
{
|
||||
<a href="/photos/@(Model.PageNumber - 1)">Previous Page</a>
|
||||
}
|
||||
<a href="/photos/@(Model.PageNumber + 1)">Next Page</a>
|
||||
|
||||
<div style="height: 100px; width: 1px;"></div> @* solves quirk with footer *@
|
|
@ -19,11 +19,16 @@ namespace LBPUnion.ProjectLighthouse.Pages
|
|||
|
||||
public List<Photo> Photos;
|
||||
|
||||
public async Task<IActionResult> OnGet()
|
||||
public int PageNumber;
|
||||
|
||||
public async Task<IActionResult> OnGet([FromRoute] int pageNumber)
|
||||
{
|
||||
const int pageSize = 20;
|
||||
this.PhotoCount = await StatisticsHelper.PhotoCount();
|
||||
|
||||
this.Photos = await this.Database.Photos.Include(p => p.Creator).Take(20).ToListAsync();
|
||||
this.PageNumber = pageNumber;
|
||||
|
||||
this.Photos = await this.Database.Photos.Include(p => p.Creator).Skip(pageNumber * pageSize).Take(pageSize).ToListAsync();
|
||||
|
||||
return this.Page();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue