bulletboards/ImageBoardServerApp/Pages/Basic/ThreadPage.razor

48 lines
1.1 KiB
Text
Raw Normal View History

2023-01-25 22:45:36 +00:00
@page "/{boardName}/thread/{threadId}"
@using System.ComponentModel.DataAnnotations
@using ImageBoardServerApp.Data.Repository
@inject NavigationManager NavigationManager
<PageTitle>Thread #@post.GET on /@boardName/ - BulletBoard</PageTitle>
2023-03-07 21:33:36 +00:00
<h3>Thread #@post.GET on /@boardName/</h3>
2023-01-25 22:45:36 +00:00
<Post post="@post" showOpenThread="false"/>
<hr/>
@foreach (var comment in post.Comments)
{
<Comment comment="comment"/>
<hr/>
}
2023-02-17 21:54:13 +00:00
<div class="Form">
<CommentForm post="post"/>
</div>
2023-01-25 22:45:36 +00:00
@code {
2023-01-25 22:45:36 +00:00
[Parameter]
[Required]
public string boardName { get; set; }
2023-01-25 22:45:36 +00:00
[Parameter]
[Required]
public string threadId { get; set; }
2023-01-25 22:45:36 +00:00
private PostData post;
protected override async Task OnInitializedAsync()
{
if (!int.TryParse(threadId, out _))
2023-01-25 22:45:36 +00:00
NavigationManager.NavigateTo("/notfound");
post = await PostsRepository.getPostByIdAsync(int.Parse(threadId));
if (post == null)
2023-01-26 08:07:25 +00:00
NavigationManager.NavigateTo("/notfound");
if (post.Board != boardName)
NavigationManager.NavigateTo("/notfound");
if (post == null)
2023-01-25 22:45:36 +00:00
NavigationManager.NavigateTo("/notfound");
}
2023-01-25 22:45:36 +00:00
}