2023-01-18 12:56:24 +00:00
|
|
|
@page "/"
|
2023-01-26 12:04:55 +00:00
|
|
|
@using ImageBoardServerApp.Data.Repository
|
2023-02-02 07:15:43 +00:00
|
|
|
@using ImageBoardServerApp.Auth
|
|
|
|
@inject AuthenticationStateProvider authStateProvider
|
2023-01-18 12:56:24 +00:00
|
|
|
|
|
|
|
<h1>BulletBoard</h1>
|
2023-01-26 12:04:55 +00:00
|
|
|
<span>This is a simple Imageboard made in Razor.</span>
|
|
|
|
<br/>
|
2023-02-07 20:21:38 +00:00
|
|
|
<span>We're currently hosting @amountOfPosts Threads, @amountOfComments Comments and @amountOfUsers Users.</span>
|
|
|
|
<sr/>
|
2023-02-02 07:15:43 +00:00
|
|
|
<span>@Details</span>
|
2023-02-12 18:06:33 +00:00
|
|
|
<AuthorizeView>
|
|
|
|
<Authorized>
|
|
|
|
<br/>
|
|
|
|
<a href="/sys/you">Edit your account</a>
|
|
|
|
</Authorized>
|
|
|
|
</AuthorizeView>
|
2023-01-26 12:04:55 +00:00
|
|
|
|
|
|
|
@code{
|
2023-02-02 07:15:43 +00:00
|
|
|
private string Details { get; set; }
|
|
|
|
|
2023-01-26 12:04:55 +00:00
|
|
|
private int amountOfPosts = -1;
|
|
|
|
private int amountOfComments = -1;
|
|
|
|
private int amountOfUsers = -1;
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
|
|
{
|
2023-02-02 07:15:43 +00:00
|
|
|
var cauthStateProvder = (CustomAuthenticationStateProvider)authStateProvider;
|
|
|
|
var user = await cauthStateProvder.GetAuthenticationStateAsync();
|
|
|
|
if (user.User.Identity.IsAuthenticated)
|
|
|
|
{
|
|
|
|
var usr = user.User.Identity.Name;
|
|
|
|
Details = $"Welcome {usr}";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Details = "Please log in first.";
|
|
|
|
}
|
2023-01-26 12:04:55 +00:00
|
|
|
var posts = await PostsRepository.getPostsAsync();
|
|
|
|
amountOfPosts = posts.Count;
|
|
|
|
var comments = await CommentsRepository.getCommentsAsync();
|
|
|
|
amountOfComments = comments.Count;
|
|
|
|
var users = await UsersRepository.getUsersAsync();
|
|
|
|
amountOfUsers = users.Count;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|