mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-08-06 03:48:40 +00:00
Add comments section to profile
This commit is contained in:
parent
87f16e3869
commit
954e2b3e7e
3 changed files with 32 additions and 1 deletions
|
@ -4,7 +4,7 @@
|
|||
<data-source source="LOCAL" name="lighthouse@localhost" uuid="3bfb85d6-6cc2-427d-9288-06e05ab58c10">
|
||||
<driver-ref>mysql.8</driver-ref>
|
||||
<synchronize>true</synchronize>
|
||||
<jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
|
||||
<jdbc-driver>com.mysql.cj.jdbc.NonRegisteringDriver</jdbc-driver>
|
||||
<jdbc-url>jdbc:mysql://localhost:3306/lighthouse</jdbc-url>
|
||||
<working-dir>$ProjectFileDir$</working-dir>
|
||||
</data-source>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
@page "/user/{userId:int}"
|
||||
@using LBPUnion.ProjectLighthouse.Types
|
||||
@using LBPUnion.ProjectLighthouse.Types.Profiles
|
||||
@using LBPUnion.ProjectLighthouse.Types.Settings
|
||||
@model LBPUnion.ProjectLighthouse.Pages.UserPage
|
||||
|
||||
|
@ -76,4 +77,23 @@
|
|||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (Model.ProfileUser.Comments > 0)
|
||||
{
|
||||
<div class="ui yellow segment">
|
||||
<h1>Comments</h1>
|
||||
@foreach (Comment comment in Model.Comments!)
|
||||
{
|
||||
DateTimeOffset timestamp = DateTimeOffset.FromUnixTimeSeconds(comment.Timestamp / 1000);
|
||||
<div>
|
||||
<b><a href="/user/@comment.PosterUserId">@comment.Poster.Username</a>: </b>
|
||||
<span>@comment.Message</span>
|
||||
<p>
|
||||
<i>@timestamp.ToString("MM/dd/yyyy @ h:mm tt") UTC</i>
|
||||
</p>
|
||||
<div class="ui divider"></div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
|
@ -4,6 +4,7 @@ using System.Linq;
|
|||
using System.Threading.Tasks;
|
||||
using LBPUnion.ProjectLighthouse.Pages.Layouts;
|
||||
using LBPUnion.ProjectLighthouse.Types;
|
||||
using LBPUnion.ProjectLighthouse.Types.Profiles;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
|
@ -15,7 +16,10 @@ namespace LBPUnion.ProjectLighthouse.Pages
|
|||
{}
|
||||
|
||||
public User? ProfileUser;
|
||||
|
||||
public List<Photo>? Photos;
|
||||
public List<Comment>? Comments;
|
||||
|
||||
public bool IsProfileUserHearted;
|
||||
|
||||
public async Task<IActionResult> OnGet([FromRoute] int userId)
|
||||
|
@ -24,6 +28,13 @@ namespace LBPUnion.ProjectLighthouse.Pages
|
|||
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();
|
||||
this.Comments = await this.Database.Comments.Include
|
||||
(p => p.Poster)
|
||||
.Include(p => p.Target)
|
||||
.OrderByDescending(p => p.Timestamp)
|
||||
.Where(p => p.TargetUserId == userId)
|
||||
.Take(50)
|
||||
.ToListAsync();
|
||||
|
||||
if (this.User != null)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue