mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-08-01 09:48:37 +00:00
Add user page
This commit is contained in:
parent
7ca9e5ae61
commit
3d9cb328e0
4 changed files with 81 additions and 5 deletions
|
@ -47,6 +47,7 @@
|
|||
<div class="ui container">
|
||||
<br>
|
||||
@RenderBody()
|
||||
<div style="height: 150px; width: 1px;"></div> @* solves quirk with footer *@
|
||||
</div>
|
||||
</body>
|
||||
<footer class="lighthouse-footer">
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
<i>
|
||||
Taken by
|
||||
<b>
|
||||
<a href="/users/@photo.Creator!.UserId">@photo.Creator.Username</a>
|
||||
<a href="/user/@photo.Creator!.UserId">@photo.Creator.Username</a>
|
||||
</b>
|
||||
</i>
|
||||
</p>
|
||||
|
@ -29,7 +29,7 @@
|
|||
</p>
|
||||
@foreach (PhotoSubject subject in photo.Subjects)
|
||||
{
|
||||
<a href="/users/@subject.UserId">@subject.User.Username</a>
|
||||
<a href="/user/@subject.UserId">@subject.User.Username</a>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
@ -38,6 +38,4 @@
|
|||
{
|
||||
<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 *@
|
||||
<a href="/photos/@(Model.PageNumber + 1)">Next Page</a>
|
47
ProjectLighthouse/Pages/UserPage.cshtml
Normal file
47
ProjectLighthouse/Pages/UserPage.cshtml
Normal file
|
@ -0,0 +1,47 @@
|
|||
@page "/user/{userId:int}"
|
||||
@using LBPUnion.ProjectLighthouse.Types
|
||||
@using LBPUnion.ProjectLighthouse.Types.Settings
|
||||
@model LBPUnion.ProjectLighthouse.Pages.UserPage
|
||||
|
||||
@{
|
||||
Layout = "Layouts/BaseLayout";
|
||||
}
|
||||
|
||||
<h1>@Model.ProfileUser!.Username's user page</h1>
|
||||
|
||||
<div>
|
||||
<i class="pink heart icon" title="Hearts"></i> @Model.ProfileUser.Hearts
|
||||
<i class="blue comment icon" title="Comments"></i> @Model.ProfileUser.Comments
|
||||
<i class="green upload icon" title="Uploaded Levels"></i>@Model.ProfileUser.UsedSlots / @ServerStatics.EntitledSlots
|
||||
<i class="purple camera icon" title="Uploaded Photos"></i>@Model.ProfileUser.PhotosByMe
|
||||
</div>
|
||||
|
||||
<div class="ui blue segment">
|
||||
<h2>Biography</h2>
|
||||
<p>@Model.ProfileUser.Biography</p>
|
||||
</div>
|
||||
|
||||
@if (Model.Photos != null && Model.Photos.Count != 0)
|
||||
{
|
||||
<div class="ui purple segment">
|
||||
<h2>Most recent photos</h2>
|
||||
|
||||
<div class="ui center aligned grid">
|
||||
@foreach (Photo photo in Model.Photos)
|
||||
{
|
||||
<div class="eight wide column">
|
||||
<img src="/gameAssets/@photo.LargeHash" style="width: 100%; height: auto; border-radius: .28571429rem;">
|
||||
<br>
|
||||
|
||||
<p>
|
||||
<b>Photo contains @photo.Subjects.Count @(photo.Subjects.Count == 1 ? "person" : "people"):</b>
|
||||
</p>
|
||||
@foreach (PhotoSubject subject in photo.Subjects)
|
||||
{
|
||||
<a href="/user/@subject.UserId">@subject.User.Username</a>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
30
ProjectLighthouse/Pages/UserPage.cshtml.cs
Normal file
30
ProjectLighthouse/Pages/UserPage.cshtml.cs
Normal file
|
@ -0,0 +1,30 @@
|
|||
#nullable enable
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using LBPUnion.ProjectLighthouse.Pages.Layouts;
|
||||
using LBPUnion.ProjectLighthouse.Types;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Pages
|
||||
{
|
||||
public class UserPage : BaseLayout
|
||||
{
|
||||
public UserPage(Database database) : base(database)
|
||||
{}
|
||||
|
||||
public User? ProfileUser;
|
||||
public List<Photo>? Photos;
|
||||
|
||||
public async Task<IActionResult> OnGet([FromRoute] int userId)
|
||||
{
|
||||
this.ProfileUser = await this.Database.Users.FirstOrDefaultAsync(u => u.UserId == userId);
|
||||
if (this.ProfileUser == null) return this.NotFound();
|
||||
|
||||
this.Photos = await this.Database.Photos.OrderByDescending(p => p.Timestamp).Where(p => p.CreatorId == userId).Take(5).ToListAsync();
|
||||
|
||||
return this.Page();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue