chore: cleanup
This commit is contained in:
parent
0e725b065a
commit
f5ac34e639
17 changed files with 67 additions and 3 deletions
|
@ -22,8 +22,23 @@ public static class CommentsRepository
|
||||||
public static async Task<CommentData> getCommentByIdAsync(int postId)
|
public static async Task<CommentData> getCommentByIdAsync(int postId)
|
||||||
{
|
{
|
||||||
await using var db = new AppDBContext();
|
await using var db = new AppDBContext();
|
||||||
return await db.Comments.FirstOrDefaultAsync(comment => comment.PostID == postId);
|
return await db.Comments
|
||||||
|
.Where(comment => comment.CommentID == postId)
|
||||||
|
.Include(comment => comment.Image)
|
||||||
|
.Include(comment => comment.Post)
|
||||||
|
.FirstOrDefaultAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*public static async Task<PostData> getPostByIdAsync(int postId)
|
||||||
|
{
|
||||||
|
await using var db = new AppDBContext();
|
||||||
|
return await db.Posts
|
||||||
|
.Where(post => post.PostID == postId)
|
||||||
|
.Include(post => post.Image)
|
||||||
|
.Include(post => post.Comments)
|
||||||
|
.FirstOrDefaultAsync();
|
||||||
|
//return await db.Posts.FirstOrDefaultAsync(post => post.PostID == postId);
|
||||||
|
}*/
|
||||||
|
|
||||||
public static async Task<int> createCommentAsync(CommentData commentData)
|
public static async Task<int> createCommentAsync(CommentData commentData)
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,6 +17,7 @@ public static class PostsRepository
|
||||||
.Where(post => post.Board.Equals(board))
|
.Where(post => post.Board.Equals(board))
|
||||||
.Include(post => post.Image)
|
.Include(post => post.Image)
|
||||||
.Include(post => post.Comments)
|
.Include(post => post.Comments)
|
||||||
|
.Include(post => post.User)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,6 +28,7 @@ public static class PostsRepository
|
||||||
.Where(post => post.PostID == postId)
|
.Where(post => post.PostID == postId)
|
||||||
.Include(post => post.Image)
|
.Include(post => post.Image)
|
||||||
.Include(post => post.Comments)
|
.Include(post => post.Comments)
|
||||||
|
.Include(post => post.User)
|
||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
//return await db.Posts.FirstOrDefaultAsync(post => post.PostID == postId);
|
//return await db.Posts.FirstOrDefaultAsync(post => post.PostID == postId);
|
||||||
}
|
}
|
||||||
|
|
17
ImageBoardServerApp/Pages/Components/ReportPage.razor
Normal file
17
ImageBoardServerApp/Pages/Components/ReportPage.razor
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
@page "/report/{type}/{board}/{id}"
|
||||||
|
@using System.ComponentModel.DataAnnotations
|
||||||
|
<h3>Report</h3>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter]
|
||||||
|
[Required]
|
||||||
|
public string type { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
[Required]
|
||||||
|
public string board { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
[Required]
|
||||||
|
public string id { get; set; }
|
||||||
|
}
|
|
@ -1,6 +1,8 @@
|
||||||
@using System.ComponentModel.DataAnnotations
|
@using System.ComponentModel.DataAnnotations
|
||||||
|
@using ImageBoardServerApp.Auth
|
||||||
@using ImageBoardServerApp.Data
|
@using ImageBoardServerApp.Data
|
||||||
@using ImageBoardServerApp.Data.Repository
|
@using ImageBoardServerApp.Data.Repository
|
||||||
|
@inject AuthenticationStateProvider authStateProvider
|
||||||
|
|
||||||
<div class="threadHeader">
|
<div class="threadHeader">
|
||||||
<span>[</span>
|
<span>[</span>
|
||||||
|
@ -35,7 +37,10 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="threadFooter">
|
<div class="threadFooter">
|
||||||
<span>[</span>
|
<span>[</span>
|
||||||
<a class="report" href="/report/@comment.Board/@comment.PostID/comment/@comment.CommentID" target="_blank">Report</a>
|
<a @onclick="@deletePost" href="javascript:void(0)">Delete</a>
|
||||||
|
<span>]</span>
|
||||||
|
<span>[</span>
|
||||||
|
<a class="report" href="/report/comment/@comment.Board/@comment.CommentID" target="_blank">Report</a>
|
||||||
<span>]</span>
|
<span>]</span>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
@ -43,6 +48,20 @@
|
||||||
|
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
|
|
||||||
|
private async Task deletePost()
|
||||||
|
{
|
||||||
|
var cauthStateProvder = (CustomAuthenticationStateProvider)authStateProvider;
|
||||||
|
var user = await cauthStateProvder.GetAuthenticationStateAsync();
|
||||||
|
var usr = user.User;
|
||||||
|
UserData foundusr = await UsersRepository.getUserByEmailAsync(usr.Identity.Name);
|
||||||
|
if (foundusr.PermissionInteger >= 50 || comment.UserID == foundusr.UserID)
|
||||||
|
{
|
||||||
|
await CommentsRepository.deleteCommentAsync(comment.CommentID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private static DateTime getTimeFromUnix(double javaTimeStamp)
|
private static DateTime getTimeFromUnix(double javaTimeStamp)
|
||||||
{
|
{
|
||||||
var dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
|
var dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
}
|
}
|
||||||
<span class="title">@post.Title</span>
|
<span class="title">@post.Title</span>
|
||||||
<span class="name">@post.Username</span>
|
<span class="name">@post.Username</span>
|
||||||
|
<span class="roleAdmin" >##@post.User.Role</span>
|
||||||
<span class="date">@getTimeFromUnix(post.CreatedAt)</span>
|
<span class="date">@getTimeFromUnix(post.CreatedAt)</span>
|
||||||
<span class="post-id">No.@post.PostID</span>
|
<span class="post-id">No.@post.PostID</span>
|
||||||
</div>
|
</div>
|
||||||
|
@ -48,7 +49,7 @@
|
||||||
<a @onclick="@deletePost" href="javascript:void(0)">Delete</a>
|
<a @onclick="@deletePost" href="javascript:void(0)">Delete</a>
|
||||||
<span>]</span>
|
<span>]</span>
|
||||||
<span>[</span>
|
<span>[</span>
|
||||||
<a class="report" href="/report/@post.Board/@post.PostID" target="_blank">Report</a>
|
<a class="report" href="/report/op/@post.Board/@post.PostID" target="_blank">Report</a>
|
||||||
<span>]</span>
|
<span>]</span>
|
||||||
@if (showOpenThread)
|
@if (showOpenThread)
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,6 +16,10 @@
|
||||||
color: #339305;
|
color: #339305;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.roleAdmin{
|
||||||
|
color: #ff191c;
|
||||||
|
}
|
||||||
|
|
||||||
.threadHeader{
|
.threadHeader{
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,12 @@
|
||||||
@using Radzen
|
@using Radzen
|
||||||
@using Radzen.Blazor
|
@using Radzen.Blazor
|
||||||
@using ImageBoardServerApp
|
@using ImageBoardServerApp
|
||||||
|
@using ImageBoardServerApp.Pages
|
||||||
|
@using ImageBoardServerApp.Pages.Boards
|
||||||
|
@using ImageBoardServerApp.Pages.Accounts
|
||||||
|
@using ImageBoardServerApp.Pages.Basic
|
||||||
|
@using ImageBoardServerApp.Pages.Components
|
||||||
|
@using ImageBoardServerApp.Pages.Status
|
||||||
@using ImageBoardServerApp.Shared
|
@using ImageBoardServerApp.Shared
|
||||||
@using ImageBoardServerApp.Shared.Components
|
@using ImageBoardServerApp.Shared.Components
|
||||||
@using ImageBoardServerApp.Shared.Components.Forms
|
@using ImageBoardServerApp.Shared.Components.Forms
|
||||||
|
|
Loading…
Reference in a new issue