@using Indotalent.Features.Organization.Department @using Indotalent.Features.Organization.Department.Cqrs @using Indotalent.Shared.Utils @using MudBlazor @inject DepartmentService DepartmentService @inject ISnackbar Snackbar
Add New Department Create a new department and assign a cost center.
Cost Center Department Name Head of Department Description Other Information 1 Other Information 2 Other Information 3
Cancel @if (_processing) { Processing... } else { Create Department }
@code { [Parameter] public EventCallback OnCancel { get; set; } [Parameter] public EventCallback OnSuccess { get; set; } private MudForm _form = default!; private CreateDepartmentValidator _validator = new(); private CreateDepartmentRequest _model = new(); private bool _processing = false; private async Task Submit() { await _form.Validate(); if (!_form.IsValid) return; _processing = true; try { var response = await DepartmentService.CreateDepartmentAsync(_model); await Task.Delay(500); if (response != null && response.IsSuccess) { Snackbar.Add("Department created successfully", Severity.Success); await OnSuccess.InvokeAsync(); } } finally { _processing = false; } } }