@page "/site-info/{SiteId:int}"
@attribute [Authorize]
@using BLAIzor.Components.Layout
@using BLAIzor.Models
@using BLAIzor.Services
@using Microsoft.AspNetCore.Components.Authorization
@layout AdminLayout
@inject ScopedContentService SiteInfoService
@inject AuthenticationStateProvider AuthenticationStateProvider
@inject CustomAuthenticationStateProvider CustomAuthProvider
Site Information
@code {
[Parameter]
public int SiteId { get; set; }
private SiteInfo siteInfo = new();
private string? userId;
private string? userName;
private AuthenticationState? authState;
protected override async Task OnParametersSetAsync()
{
authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
if (authState.User.Identity?.IsAuthenticated == true)
{
userId = CustomAuthProvider.GetUserId();
userName = CustomAuthProvider.GetUserName();
}
siteInfo = await SiteInfoService.GetSiteInfoByIdAsync(SiteId) ?? new SiteInfo();
}
private async Task SaveSiteInfo()
{
await SiteInfoService.UpdateSiteInfoAsync(siteInfo);
}
}