bulletboards/ImageBoardServerApp/Pages/Basic/ThreadPage.razor

48 lines
1.1 KiB
Text
Raw Normal View History

2023-01-25 23:45:36 +01: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 22:33:36 +01:00
<h3>Thread #@post.GET on /@boardName/</h3>
2023-01-25 23:45:36 +01:00
<Post post="@post" showOpenThread="false"/>
<hr/>
@foreach (var comment in post.Comments)
{
<Comment comment="comment"/>
<hr/>
}
2023-02-17 22:54:13 +01:00
<div class="Form">
<CommentForm post="post"/>
</div>
2023-01-25 23:45:36 +01:00
@code {
2023-01-25 23:45:36 +01:00
[Parameter]
[Required]
public string boardName { get; set; }
2023-01-25 23:45:36 +01:00
[Parameter]
[Required]
public string threadId { get; set; }
2023-01-25 23:45:36 +01:00
private PostData post;
protected override async Task OnInitializedAsync()
{
if (!int.TryParse(threadId, out _))
2023-01-25 23:45:36 +01:00
NavigationManager.NavigateTo("/notfound");
post = await PostsRepository.getPostByIdAsync(int.Parse(threadId));
if (post == null)
2023-01-26 09:07:25 +01:00
NavigationManager.NavigateTo("/notfound");
if (post.Board != boardName)
NavigationManager.NavigateTo("/notfound");
if (post == null)
2023-01-25 23:45:36 +01:00
NavigationManager.NavigateTo("/notfound");
}
2023-01-25 23:45:36 +01:00
}