80 lines
2.1 KiB
C#
80 lines
2.1 KiB
C#
using GPW.CORE.Data.DbModels;
|
|
using GPW.CORE.Smart.Data;
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
namespace GPW.CORE.Smart.Components.Compo
|
|
{
|
|
public partial class TimbAdmin
|
|
{
|
|
#region Public Properties
|
|
|
|
[Parameter]
|
|
public int IdxDipAdmin { get; set; } = 0;
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Protected Methods
|
|
|
|
/// <summary>
|
|
/// Aggiorno e riporto update
|
|
/// </summary>
|
|
protected async void DoUpdate(bool forceReload)
|
|
{
|
|
if (forceReload)
|
|
{
|
|
isLoading= true;
|
|
await Task.Delay(1);
|
|
await ReloadData();
|
|
await Task.Delay(1);
|
|
isLoading = false;
|
|
await InvokeAsync(StateHasChanged);
|
|
}
|
|
}
|
|
|
|
protected override async Task OnParametersSetAsync()
|
|
{
|
|
// verifico se il dip sia admin...
|
|
var listaRuoli = await CDService.Dip2RuoliGetAll();
|
|
var rigaDip = listaRuoli.FirstOrDefault(x => x.IdxDipendente == IdxDipAdmin && x.CodRuolo == "AppMancTimb");
|
|
userIsAdmin = rigaDip != null;
|
|
await ReloadData();
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private bool userIsAdmin = false;
|
|
|
|
private bool isLoading = false;
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
[Inject]
|
|
private CoreSmartDataService CDService { get; set; } = null!;
|
|
|
|
private List<TimbratureModel>? ListTimbRich { get; set; } = null;
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
private async Task ReloadData()
|
|
{
|
|
ListTimbRich = null;
|
|
await Task.Delay(1);
|
|
if (userIsAdmin)
|
|
{
|
|
var rawData = await CDService.TimbratureRichieste();
|
|
ListTimbRich = rawData
|
|
.OrderByDescending(x => x.DataOra)
|
|
.ToList();
|
|
}
|
|
await Task.Delay(1);
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |