@using Indotalent.Features.Utilities.BookingResource @using Indotalent.Features.Utilities.BookingResource.Cqrs @using Indotalent.Shared.Utils @using MudBlazor @inject BookingResourceService BookingResourceService @inject ISnackbar Snackbar Add New Booking Resource Define a new bookable asset and its category. Resource Name Booking Group @foreach (var item in _lookupData.BookingGroups) { @item.Name } Description Cancel @if (_processing) { Processing... } else { Create Resource } @code { [Parameter] public EventCallback OnCancel { get; set; } [Parameter] public EventCallback OnSuccess { get; set; } private MudForm _form = default!; private CreateBookingResourceValidator _validator = new(); private CreateBookingResourceRequest _model = new(); private LookupBookingGroupResponse _lookupData = new(); private bool _processing = false; protected override async Task OnInitializedAsync() { var response = await BookingResourceService.GetBookingGroupLookupAsync(); if (response != null && response.IsSuccess) { _lookupData = response.Value!; } } private async Task Submit() { await _form.Validate(); if (!_form.IsValid) return; _processing = true; try { var response = await BookingResourceService.CreateBookingResourceAsync(_model); await Task.Delay(500); if (response != null && response.IsSuccess) { Snackbar.Add("Booking resource created successfully", Severity.Success); await OnSuccess.InvokeAsync(); } } catch (Exception ex) { Snackbar.Add($"Error: {ex.Message}", Severity.Error); } finally { _processing = false; } } }