using Microsoft.AspNetCore.Components; using Microsoft.JSInterop; using MP.Data.DbModels; using MP.SPEC.Data; namespace MP.SPEC.Components.ProdKit { public partial class KitVerify { #region Public Properties [Parameter] public List AllRecPODL { get; set; } = new List(); [Parameter] public List AllRecTSM { get; set; } = new List(); [Parameter] public List AllRecWSM { get; set; } = new List(); [Parameter] public EventCallback EC_KitCreated { get; set; } [Parameter] public string KeyFilt { get; set; } = ""; [Parameter] public List PodlRecords { get; set; } = new List(); #endregion Public Properties #region Protected Properties [Inject] protected IJSRuntime JSRuntime { get; set; } = null!; [Inject] protected MpDataService MDService { get; set; } = null!; #endregion Protected Properties #region Protected Methods protected void KitToggleDetail(TksScoreModel? currRec) { CodArtParent = currRec != null ? currRec.CodArtParent : ""; if (!string.IsNullOrEmpty(CodArtParent)) { ListKitTemplate = MDService.TemplateKitFilt(CodArtParent, ""); totalKitCount = ListKitTemplate.Count; ListRecKitPODL = PodlRecords .Where(x => !string.IsNullOrEmpty(x.KeyRichiesta) && x.KeyRichiesta.StartsWith("KIT") && x.CodArticolo==CodArtParent) .ToList(); } else { ListKitTemplate = null; totalKitCount = 0; } doShowDetail = !doShowDetail; } protected override void OnParametersSet() { ReloadData(); } #endregion Protected Methods #region Private Fields private string CodArtParent = ""; private bool doShowDetail = false; private List? ListKitTemplate = null; private List ListRecPODL = new List(); private List ListRecKitPODL = new List(); private List ListRecScore = new List(); /// /// Num record composizione kit... /// private int numRecWsm = 0; private int totalKitCount = 0; #endregion Private Fields #region Private Methods /// /// Crea una NUOVA istanza KIT /// /// Record selezionato da generare x Assieme/KIT private async Task DoCreatePOdl(TksScoreModel currRec) { if (!await JSRuntime.InvokeAsync("confirm", "Confermi di voler creare il PODL del KIT selezionato?")) return; // eseguo stored... bool fatto = MDService.IstKitInsertByWKS(currRec.CodArtParent, KeyFilt); if (fatto) { // segnalo update await EC_KitCreated.InvokeAsync(true); } } private void ReloadData() { ListRecScore = AllRecTSM.ToList(); ListRecPODL = AllRecPODL.ToList(); numRecWsm = AllRecWSM.Count(); } #endregion Private Methods } }