Files
mapo-core/MP.INVE/Shared/NavMenu.razor.cs
T
zaccaria.majid 3dddc33ec1 fix doppia chiamata al db causa:
handleclick nel nav manager
2022-11-18 09:12:23 +01:00

78 lines
2.5 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components;
using System.Net.Http;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.AspNetCore.Components.Forms;
using Microsoft.AspNetCore.Components.Routing;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.Web.Virtualization;
using Microsoft.JSInterop;
using MP.INVE;
using MP.INVE.Shared;
using MP.INVE.Components;
using MP.INVE.Data;
using MP.Data.DTO;
using Blazored.LocalStorage;
namespace MP.INVE.Shared
{
public partial class NavMenu
{
private bool collapseNavMenu = true;
//public List<MP.Data.DatabaseModels.LinkMenu>? ElencoLink { get; set; }
private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null;
private void ToggleNavMenu()
{
collapseNavMenu = !collapseNavMenu;
}
protected string userName { get; set; } = "0";
protected async Task getId()
{
OperatoreDTO answ = new OperatoreDTO();
answ = await localStorage.GetItemAsync<OperatoreDTO>("MatrOpr");
if (answ != null)
{
userName = $"{answ.Cognome} {answ.Nome} ({answ.MatrOpr})";
if (NavigationManager.Uri.Contains("OperatoreLogin"))
{
NavigationManager.NavigateTo("Starter", true);
}
}
else
{
userName = "0";
if (!NavigationManager.Uri.Contains("OperatoreLogin"))
{
NavigationManager.NavigateTo("OperatoreLogin", true);
}
}
}
protected override async Task OnInitializedAsync()
{
// recupero elenco JQM
//ElencoLink = await MDService.ElencoLink();
await getId();
}
protected bool showText { get; set; } = true;
protected void ToggleCompress()
{
showText = !showText;
EC_compressUpdated.InvokeAsync(showText);
}
protected string hideText { get => showText ? "" : "invisible"; }
[Parameter]
public EventCallback<bool> EC_compressUpdated { get; set; }
[Inject]
protected ILocalStorageService localStorage { get; set; } = null!;
[Inject]
protected NavigationManager NavigationManager { get; set; } = null!;
}
}