@using Indotalent.Features.Payroll.Payrolls @using Indotalent.Features.Payroll.Payrolls.Cqrs @using MudBlazor @inject PayrollsService PayrollsService @inject ISnackbar Snackbar Calculate New Payroll Specify the period to run the salary engine for all active employees. Period Name From Date To Date Description / Notes Cancel @if (_processing) { Executing Engine... } else { Run Calculation } @code { [Parameter] public EventCallback OnCancel { get; set; } [Parameter] public EventCallback OnSuccess { get; set; } private MudForm _form = default!; private CreatePayrollProcessRequest _model = new() { FromDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1), ToDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month)) }; private bool _processing = false; private async Task Submit() { await _form.Validate(); if (!_form.IsValid) return; _processing = true; try { var response = await PayrollsService.CreatePayrollProcessAsync(_model); if (response != null && response.IsSuccess) { Snackbar.Add("Payroll has been calculated successfully", Severity.Success); await OnSuccess.InvokeAsync(); } } catch (Exception ex) { Snackbar.Add($"Error: {ex.Message}", Severity.Error); } finally { _processing = false; } } }