Files
lux/Lux.UI/Components/Pages/Dealer.razor.cs
T
2026-05-29 11:18:07 +02:00

104 lines
2.3 KiB
C#

namespace Lux.UI.Components.Pages
{
public partial class Dealer
{
#region Protected Methods
protected override async Task OnInitializedAsync()
{
isLoading = true;
await ReloadBaseDataAsync();
isLoading = false;
}
#endregion Protected Methods
#region Private Fields
private DealerModel? editRecord = null;
private bool isLoading = false;
private List<DealerModel> ListDealer = new List<DealerModel>();
#endregion Private Fields
#region Private Properties
[Inject]
private IDealerService DService { get; set; } = null!;
private string searchVal { get; set; } = string.Empty;
#endregion Private Properties
#region Private Methods
private void DoAdd()
{
editRecord = new DealerModel()
{
CompanyName = "Nuovo Fornitore",
FirstName = "Nuovo",
LastName = "Fornitore",
VAT = "0000000000000000"
};
}
private void DoCancel()
{
editRecord = null;
}
private async Task DoReloadAsync(bool force)
{
editRecord = null;
if (force)
await ReloadBaseDataAsync();
}
private async Task DoSaveSelCustomer(DealerModel currRec)
{
isLoading = true;
// salvo
await DService.UpsertAsync(currRec);
editRecord = null;
await ReloadBaseDataAsync();
}
private void EditCustomer(DealerModel editRec)
{
editRecord = editRec;
}
private async Task ReloadBaseDataAsync()
{
ListDealer = await DService.GetAllAsync();
isLoading = false;
}
private string SearchVal
{
get => searchVal;
set
{
if (searchVal != value)
{
searchVal = value;
}
}
}
private string btnResetCss
{
get => string.IsNullOrEmpty(searchVal) ? "btn-outline-secondary" : "btn-primary";
}
private void ResetSearch()
{
SearchVal = "";
}
#endregion Private Methods
}
}