104 lines
2.4 KiB
C#
104 lines
2.4 KiB
C#
|
|
namespace Lux.UI.Components.Pages
|
|
{
|
|
public partial class Customer
|
|
{
|
|
|
|
#region Protected Methods
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
isLoading = true;
|
|
await ReloadBaseDataAsync();
|
|
isLoading = false;
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private CustomerModel? editRecord = null;
|
|
|
|
private bool isLoading = false;
|
|
|
|
private List<CustomerModel> ListCustomer = new List<CustomerModel>();
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
[Inject]
|
|
private ICustomerService CService { get; set; } = null!;
|
|
|
|
private string searchVal { get; set; } = string.Empty;
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
private void DoAdd()
|
|
{
|
|
editRecord = new CustomerModel()
|
|
{
|
|
CompanyName = "Nuovo Cliente",
|
|
FirstName = "Nuovo",
|
|
LastName = "Cliente",
|
|
VAT = "0000000000000000"
|
|
};
|
|
}
|
|
|
|
private void DoCancel()
|
|
{
|
|
editRecord = null;
|
|
}
|
|
|
|
private async Task DoReloadAsync(bool force)
|
|
{
|
|
editRecord = null;
|
|
if (force)
|
|
await ReloadBaseDataAsync();
|
|
}
|
|
private async Task DoSaveSelCustomer(CustomerModel currRec)
|
|
{
|
|
isLoading = true;
|
|
// salvo
|
|
await CService.UpsertAsync(currRec);
|
|
editRecord = null;
|
|
await ReloadBaseDataAsync();
|
|
}
|
|
|
|
private void EditCustomer(CustomerModel editRec)
|
|
{
|
|
editRecord = editRec;
|
|
}
|
|
|
|
private async Task ReloadBaseDataAsync()
|
|
{
|
|
ListCustomer = await CService.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
|
|
}
|
|
} |