Files
mapo-core/MP.SPEC/Components/CmpTop.razor.cs
T
2022-12-02 17:05:07 +01:00

81 lines
1.9 KiB
C#

using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.JSInterop;
using MP.SPEC.Data;
namespace MP.SPEC.Components
{
public partial class CmpTop
{
#region Public Methods
public async Task flushCache()
{
await Task.Delay(1);
await MDService.FlushRedisCache();
await Task.Delay(1);
// rimando a pagina corrente
NavManager.NavigateTo(NavManager.Uri, true);
}
#endregion Public Methods
#region Protected Properties
[Inject]
protected IJSRuntime JSRuntime { get; set; } = null!;
[Inject]
protected MpDataService MDService { get; set; } = null!;
#endregion Protected Properties
#region Protected Methods
protected override async Task OnInitializedAsync()
{
await forceReload();
}
#endregion Protected Methods
#region Private Fields
private string userName = "";
#endregion Private Fields
#region Private Properties
[Inject]
private NavigationManager NavManager { get; set; } = null!;
#endregion Private Properties
#region Private Methods
private async Task forceReload()
{
var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
var user = authState.User;
if (user.Identity != null && user.Identity.IsAuthenticated)
{
userName = $"{user.Identity.Name}";
}
else
{
userName = "N.A.";
}
}
private async void MService_EA_ShowSearch()
{
await Task.Delay(1);
await InvokeAsync(() => StateHasChanged());
}
#endregion Private Methods
}
}