using global::Microsoft.AspNetCore.Components; using MP.Data.DatabaseModels; using MP.Data.Services; namespace MP_TAB3.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 async Task ForceReload() { IsLoading = true; await Task.Delay(50); IsLoading = false; } protected override async Task OnInitializedAsync() { await ReloadData(); } protected async Task RefreshData(List 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 void SetMacc(string selIdxMacc) { IdxMaccSubSel = selIdxMacc; } #endregion Protected Methods #region Private Fields private string IdxMaccSubSel = ""; private bool IsLoading = false; #endregion Private Fields #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 } }