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 ListDealer = new List(); #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 } }