Files

135 lines
3.7 KiB
C#

using Microsoft.AspNetCore.Components;
using SHERPA.BBM.CORE.DbModels;
using SHERPA.BBM.UI.Data;
namespace SHERPA.BBM.UI.Pages
{
public partial class ImportExt
{
#region Public Methods
public void Dispose()
{
MService.EA_SearchUpdated -= OnSeachUpdated;
}
public async void OnSeachUpdated()
{
await ReloadData();
}
#endregion Public Methods
#region Protected Enums
protected enum ModoSync
{
ND,
Clienti,
ClientiInt,
ClientiNoLink,
Fatture,
FattureNoLinkCli,
FattureNoLinkOrd,
Ordini
}
#endregion Protected Enums
#region Protected Properties
[Inject]
protected BBM_EFService BBMService { get; set; } = null!;
[Inject]
protected MessageService MService { get; set; } = null!;
#endregion Protected Properties
#region Protected Methods
protected string cssByMode(ModoSync reqMode)
{
return reqMode == currMode ? "bg-dark text-light" : "";
}
protected async Task DoReload(bool forceReload)
{
isLoading = true;
await Task.Delay(1);
if (forceReload)
{
await BBMService.FlushRedisCache();
}
await ReloadData();
}
protected override async Task OnInitializedAsync()
{
isLoading = true;
MService.NotifyHeadChanged();
MService.ShowSearch = true;
MService.EA_SearchUpdated += OnSeachUpdated;
await Task.Delay(1);
await ReloadData();
}
protected async Task SetMode(ModoSync modeReq)
{
await Task.Delay(1);
currMode = modeReq;
}
#endregion Protected Methods
#region Private Fields
private ModoSync currMode = ModoSync.ND;
#endregion Private Fields
#region Private Properties
private SelData currFilter { get; set; } = new SelData();
private bool isLoading { get; set; } = false;
private List<BillingExtModel> ListBillExt { get; set; } = null!;
private List<BillingExtModel> ListBillExtNRCli { get; set; } = null!;
private List<BillingExtModel> ListBillExtNROrd { get; set; } = null!;
private List<CustomersModel> ListClienti { get; set; } = null!;
private List<CustDecodModel> ListClientiExt { get; set; } = null!;
private List<CustDecodModel> ListClientiExtNR { get; set; } = null!;
private List<vOrderDataModel> ListOrd { get; set; } = null!;
#endregion Private Properties
#region Private Methods
private async Task ReloadData()
{
isLoading = true;
ListClienti = await BBMService.CustomersGetAll("");
ListClientiExt = await BBMService.CustDecodedGetAll();
ListClientiExtNR = ListClientiExt
.Where(x => (x.BillExtNav.Count() > 0) && (x.CustomerId == 0))
.ToList();
ListOrd = await BBMService.OrderGetFilt(currFilter);
ListBillExt = await BBMService.BillingExtGetFilt(0, 0, "", -1);
ListBillExtNRCli = ListBillExt
.Where(x => (x.CustomerId == 0))
.ToList();
ListBillExtNROrd = ListBillExt
.Where(x => (x.B2ONav.Count == 0))
.ToList();
isLoading = false;
}
#endregion Private Methods
}
}