@using Indotalent.Features.Sales.SalesQuotation.Cqrs @using MudBlazor @inject SalesQuotationService SalesQuotationService @inject ISnackbar Snackbar Product @foreach (var item in _lookup.Products) { @item.Name } Unit Price Quantity Summary Cancel @if (_processing) { Updating... } else { Save Changes } @code { [CascadingParameter] IMudDialogInstance MudDialog { get; set; } = default!; [Parameter] public SalesQuotationItemResponse Data { get; set; } = new(); private MudForm _form = default!; private UpdateSalesQuotationItemRequest _model = new(); private SalesQuotationLookupResponse _lookup = new(); private bool _processing = false; protected override async Task OnInitializedAsync() { var res = await SalesQuotationService.GetSalesQuotationLookupAsync(); if (res != null && res.IsSuccess) { _lookup = res.Value ?? new(); } _model.Id = Data.Id; _model.ProductId = Data.ProductId; _model.Summary = Data.Summary; _model.UnitPrice = Data.UnitPrice; _model.Quantity = Data.Quantity; StateHasChanged(); } private void Cancel() => MudDialog.Cancel(); private async Task Submit() { await _form.Validate(); if (!_form.IsValid) return; _processing = true; try { var response = await SalesQuotationService.UpdateSalesQuotationItemAsync(_model); await Task.Delay(500); if (response != null && response.IsSuccess) { Snackbar.Add("Item updated successfully", Severity.Success); MudDialog.Close(DialogResult.Ok(true)); } } finally { _processing = false; } } }