using EgwCoreLib.Lux.Data.DbModel.Supplier; using EgwCoreLib.Lux.Data.DbModel.Warehouse; using EgwCoreLib.Lux.Data.Services.Supplier; namespace Lux.UI.Components.Pages { public partial class BuyOrder { #region Protected Methods protected override async Task OnInitializedAsync() { await ReloadDataAsync(); await base.OnInitializedAsync(); } #endregion Protected Methods #region Private Fields private List BuyOrdAllRecords = new List(); private Dictionary> CurrSelDict = new(); private List MatReqAllRecords = new List(); #endregion Private Fields #region Private Properties [Inject] private IBuyOrderService BOService { get; set; } = null!; [Inject] private IMatReqService MRService { get; set; } = null!; private bool isProcessing = false; #endregion Private Properties #region Private Methods /// /// Crea un ordine di acquisto + relative righe... /// /// /// /// private async Task CreateBuyOrder(KeyValuePair> ReqInfo) { isProcessing = true; Dictionary> dictReq = new Dictionary>(); dictReq.Add(ReqInfo.Key, ReqInfo.Value); await BOService.GenerateFromSelectionAsync(dictReq); // invalido la cache await MRService.ClearClassCache(); await BOService.ClearClassCache(); // elimino sel x quella classe... if (CurrSelDict.ContainsKey(ReqInfo.Key)) { CurrSelDict.Remove(ReqInfo.Key); } // rileggo dati await ReloadDataAsync(); } private void RecordUpdate(Dictionary> newDictionary) { CurrSelDict = newDictionary; } private async Task ReloadDataAsync() { MatReqAllRecords = await MRService.GetUnprocAsync(); BuyOrdAllRecords = await BOService.GetAllAsync(); isProcessing = false; } private string DimensionColCss() { return CurrSelDict.Count > 0 ? "col-5" : "col-6"; } private async Task SaveBuyOrder(BuyOrderModel item) { await BOService.UpsertAsync(item); await ReloadDataAsync(); } #endregion Private Methods } }