Files
lux/Lux.UI/Components/Compo/OfferCommonPar.razor.cs
T
Samuele Locatelli d504eecbf4 Fix gestione profili
2025-10-22 11:03:52 +02:00

130 lines
3.7 KiB
C#

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<bool> EC_Close { get; set; }
[Parameter]
public EventCallback<OfferModel> EC_Updated { get; set; }
#endregion Public Properties
#region Protected Properties
[Inject]
protected ConfigDataService CDService { get; set; } = null!;
[Inject]
protected DataLayerServices DLService { get; set; } = null!;
/// <summary>
/// Gestione selezione Colore
/// </summary>
protected string SelColor
{
get => CurrSel.GetVal("Color");
set => CurrSel.SetVal("Color", value);
}
/// <summary>
/// Gestione selezione Glass
/// </summary>
protected string SelGlass
{
get => CurrSel.GetVal("Glass");
set => CurrSel.SetVal("Glass", value);
}
/// <summary>
/// Gestione selezione Profile
/// </summary>
protected string SelProfile
{
get => CurrSel.GetVal("Profile");
set => CurrSel.SetVal("Profile", value);
}
/// <summary>
/// Gestione selezione Wood
/// </summary>
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 = CDService.ProfileList(EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW, "Default");
var AllConfWood = await DLService.ConfWoodGetAllAsync();
// conversione tipi
ListColors = AllColors
.Select(x => x.ValString)
.ToList();
ListGlass = AllConfGlass
.Select(x => x.Description)
.ToList();
ListProfiles = AllConfProfile;
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<string> ListColors = new List<string>();
private List<string> ListGlass = new List<string>();
private List<string> ListProfiles = new List<string>();
private List<string> ListWood = new List<string>();
#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
}
}