Files
Annamaria Sassi 8525d81201 Correzioni
2026-04-28 18:47:30 +02:00

90 lines
2.6 KiB
C#

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<BuyOrderModel> BuyOrdAllRecords = new List<BuyOrderModel>();
private Dictionary<string, List<int>> CurrSelDict = new();
private List<MatReqModel> MatReqAllRecords = new List<MatReqModel>();
#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
/// <summary>
/// Crea un ordine di acquisto + relative righe...
/// </summary>
/// <param name="codGroup"></param>
/// <param name="listItemId"></param>
/// <returns></returns>
private async Task CreateBuyOrder(KeyValuePair<string, List<int>> ReqInfo)
{
isProcessing = true;
Dictionary<string, List<int>> dictReq = new Dictionary<string, List<int>>();
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<string, List<int>> 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
}
}