bulletboards/ImageBoardServerApp/Pages/Basic/Index.razor

46 lines
1.4 KiB
Text
Raw Normal View History

2023-01-18 12:56:24 +00:00
@page "/"
@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>
<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>
@code{
2023-02-02 07:15:43 +00:00
private string Details { get; set; }
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.";
}
var posts = await PostsRepository.getPostsAsync();
amountOfPosts = posts.Count;
var comments = await CommentsRepository.getCommentsAsync();
amountOfComments = comments.Count;
var users = await UsersRepository.getUsersAsync();
amountOfUsers = users.Count;
}
}