using EgwCoreLib.Lux.Core; using EgwCoreLib.Lux.Data.DbModel.Sales; using EgwCoreLib.Lux.Data.Services; using Microsoft.AspNetCore.Components; namespace Lux.UI.Components.Compo { public partial class OfferCommonPar { #region Public Properties [Parameter] public OfferModel CurrRecord { get; set; } = null!; [Parameter] public EventCallback EC_Close { get; set; } [Parameter] public EventCallback EC_Updated { get; set; } #endregion Public Properties #region Protected Properties [Inject] protected DataLayerServices DLService { get; set; } = null!; /// /// Gestione selezione Colore /// protected string SelColor { get => CurrSel.GetVal("Color"); set => CurrSel.SetVal("Color", value); } /// /// Gestione selezione Glass /// protected string SelGlass { get => CurrSel.GetVal("Glass"); set => CurrSel.SetVal("Glass", value); } /// /// Gestione selezione Profile /// protected string SelProfile { get => CurrSel.GetVal("Profile"); set => CurrSel.SetVal("Profile", value); } /// /// Gestione selezione Wood /// protected string SelWood { get => CurrSel.GetVal("Wood"); set => CurrSel.SetVal("Wood", value); } #endregion Protected Properties #region Protected Methods protected override async Task OnParametersSetAsync() { isLoading = true; // deserializzo se possibile dal record... CurrSel = new ParamDict(CurrRecord.DictPresel); // leggo dati di base var AllColors = await DLService.GenValGetFiltAsync("WoodCol"); var AllConfGlass = await DLService.ConfGlassGetAllAsync(); var AllConfProfile = await DLService.ConfProfileGetAllAsync(); var AllConfWood = await DLService.ConfWoodGetAllAsync(); // conversione tipi ListColors = AllColors .Select(x => x.ValString) .ToList(); ListGlass = AllConfGlass .Select(x => x.Description) .ToList(); ListProfiles = AllConfProfile .Select(x => x.Description) .ToList(); ListWood = AllConfWood .Select(x => x.Description) .ToList(); isLoading = false; } #endregion Protected Methods #region Private Fields private ParamDict CurrSel = new ParamDict(""); private bool isLoading = false; private List ListColors = new List(); private List ListGlass = new List(); private List ListProfiles = new List(); private List ListWood = new List(); #endregion Private Fields #region Private Methods private async Task DoCancel() { await EC_Close.InvokeAsync(true); } private async Task DoSave() { // aggiorno valore serializzato... CurrRecord.DictPresel = CurrSel.Serialized; // richiesta update con salvataggio record await EC_Updated.InvokeAsync(CurrRecord); } #endregion Private Methods } }