40 lines
No EOL
1.3 KiB
Text
40 lines
No EOL
1.3 KiB
Text
@page "/"
|
|
@using ImageBoardServerApp.Data.Repository
|
|
@using ImageBoardServerApp.Auth
|
|
@inject AuthenticationStateProvider authStateProvider
|
|
|
|
<h1>BulletBoard</h1>
|
|
<span>This is a simple Imageboard made in Razor.</span>
|
|
<br/>
|
|
<span>We're currently hosting @amountOfPosts Threads with @amountOfComments Comments from @amountOfUsers Users.</span>
|
|
<br/>
|
|
<span>@Details</span>
|
|
|
|
@code{
|
|
private string Details { get; set; }
|
|
|
|
private int amountOfPosts = -1;
|
|
private int amountOfComments = -1;
|
|
private int amountOfUsers = -1;
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
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.";
|
|
}
|
|
var posts = await PostsRepository.getPostsAsync();
|
|
amountOfPosts = posts.Count;
|
|
var comments = await CommentsRepository.getCommentsAsync();
|
|
amountOfComments = comments.Count;
|
|
var users = await UsersRepository.getUsersAsync();
|
|
amountOfUsers = users.Count;
|
|
}
|
|
|
|
} |