Files
mapo-core/MP-TAB-SERV/Pages/Controls.razor.cs
T
2023-12-12 08:57:09 +01:00

71 lines
1.8 KiB
C#

using global::Microsoft.AspNetCore.Components;
using MP.Data.DatabaseModels;
using MP.Data.Services;
namespace MP_TAB_SERV.Pages
{
public partial class Controls
{
#region Protected Properties
protected MappaStatoExpl? CurrMSE { get; set; } = null;
protected string IdxMacc { get; set; } = "";
[Inject]
protected MessageService MsgServ { get; set; } = null!;
#endregion Protected Properties
#region Protected Methods
protected override async Task OnInitializedAsync()
{
await ReloadData();
}
protected async Task RefreshData(List<MappaStatoExpl> newList)
{
var ListMSE = newList;
if (!string.IsNullOrEmpty(IdxMacc))
{
var rawData = ListMSE.Find(x => x.IdxMacchina == IdxMacc);
if (rawData != null)
{
CurrMSE = rawData;
}
else
{
await ReloadData();
}
}
await InvokeAsync(StateHasChanged);
}
protected async Task ForceReload()
{
IsLoading = true;
await Task.Delay(50);
IsLoading = false;
}
private bool IsLoading = false;
#endregion Protected Methods
#region Private Methods
private async Task ReloadData()
{
if (string.IsNullOrEmpty(IdxMacc))
{
IdxMacc = await MsgServ.IdxMaccGet();
// recupero MSE macchina....
if (!string.IsNullOrEmpty(IdxMacc))
{
CurrMSE = await MsgServ.GetMachineMse(IdxMacc);
}
}
}
#endregion Private Methods
}
}