mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-29 16:38:37 +00:00
Add simple photos page
This commit is contained in:
parent
4b69192e89
commit
b137d3fc79
4 changed files with 55 additions and 5 deletions
|
@ -13,5 +13,7 @@ namespace LBPUnion.ProjectLighthouse.Helpers
|
|||
public static async Task<int> SlotCount() => await database.Slots.CountAsync();
|
||||
|
||||
public static async Task<int> MMPicksCount() => await database.Slots.CountAsync(s => s.TeamPick);
|
||||
|
||||
public static async Task<int> PhotoCount() => await database.Photos.CountAsync();
|
||||
}
|
||||
}
|
|
@ -28,6 +28,7 @@ namespace LBPUnion.ProjectLighthouse.Pages.Layouts
|
|||
public readonly List<PageNavigationItem> NavigationItems = new()
|
||||
{
|
||||
new PageNavigationItem("Home", "/", "home"),
|
||||
new PageNavigationItem("Photos", "/photos", "camera"),
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
@page
|
||||
@page "/photos"
|
||||
@using LBPUnion.ProjectLighthouse.Types
|
||||
@model LBPUnion.ProjectLighthouse.Pages.PhotosPage
|
||||
|
||||
@{
|
||||
|
@ -6,3 +7,28 @@
|
|||
}
|
||||
|
||||
<h1>Photos</h1>
|
||||
<p>There are @Model.PhotoCount total photos!</p>
|
||||
|
||||
@foreach (Photo photo in Model.Photos)
|
||||
{
|
||||
<div class="ui segment">
|
||||
<img src="/gameAssets/@photo.LargeHash" style="width: 100%; height: auto; border-radius: .28571429rem;"><br>
|
||||
|
||||
<p>
|
||||
<i>
|
||||
Taken by
|
||||
<b>
|
||||
<a href="/users/@photo.Creator!.UserId">@photo.Creator.Username</a>
|
||||
</b>
|
||||
</i>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Photo contains @photo.Subjects.Count @(photo.Subjects.Count == 1 ? "person" : "people"):</b>
|
||||
</p>
|
||||
@foreach (PhotoSubject subject in photo.Subjects)
|
||||
{
|
||||
<a href="/users/@subject.UserId">@subject.User.Username</a>
|
||||
}
|
||||
</div>
|
||||
}
|
|
@ -1,10 +1,31 @@
|
|||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using JetBrains.Annotations;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Pages.Layouts;
|
||||
using LBPUnion.ProjectLighthouse.Types;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Pages
|
||||
{
|
||||
public class PhotosPage : PageModel
|
||||
public class PhotosPage : BaseLayout
|
||||
{
|
||||
public void OnGet()
|
||||
public PhotosPage([NotNull] Database database) : base(database)
|
||||
{}
|
||||
|
||||
public int PhotoCount;
|
||||
|
||||
public List<Photo> Photos;
|
||||
|
||||
public async Task<IActionResult> OnGet()
|
||||
{
|
||||
this.PhotoCount = await StatisticsHelper.PhotoCount();
|
||||
|
||||
this.Photos = await this.Database.Photos.Include(p => p.Creator).Take(20).ToListAsync();
|
||||
|
||||
return this.Page();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue