@using Indotalent.ConfigBackEnd.Extensions @using Indotalent.Features.Organization.Designation @using Indotalent.Features.Organization.Designation.Cqrs @using Indotalent.Shared.Utils @using MudBlazor @inject DesignationService DesignationService @inject ISnackbar Snackbar @(ReadOnly ? "Designation Details" : "Edit Designation") @(ReadOnly ? "Viewing designation profile." : "Modify existing designation information.") Designation Code Designation Name Career Level Description Other Information 1 Other Information 2 Other Information 3 Audit History Created At @DateTimeExtensions.ToString(_model.CreatedAt) Created By @(!string.IsNullOrEmpty(_model.CreatedBy) ? _model.CreatedBy : "System") Last Updated At @DateTimeExtensions.ToString(_model.UpdatedAt) Last Updated By @(!string.IsNullOrEmpty(_model.UpdatedBy) ? _model.UpdatedBy : "System") @(ReadOnly ? "Back to List" : "Cancel") @if (!ReadOnly) { @if (_processing) { Updating... } else { Save Changes } } @code { [Parameter] public UpdateDesignationRequest Data { get; set; } = new(); [Parameter] public bool ReadOnly { get; set; } = false; [Parameter] public EventCallback OnCancel { get; set; } [Parameter] public EventCallback OnSuccess { get; set; } private MudForm _form = default!; private UpdateDesignationValidator _validator = new(); private UpdateDesignationRequest _model = new(); private bool _processing = false; protected override void OnInitialized() => _model = new UpdateDesignationRequest { Id = Data.Id, Code = Data.Code, Name = Data.Name, Description = Data.Description, Level = Data.Level, OtherInformation1 = Data.OtherInformation1, OtherInformation2 = Data.OtherInformation2, OtherInformation3 = Data.OtherInformation3, CreatedAt = Data.CreatedAt, CreatedBy = Data.CreatedBy, UpdatedAt = Data.UpdatedAt, UpdatedBy = Data.UpdatedBy }; private async Task Submit() { await _form.Validate(); if (!_form.IsValid) return; _processing = true; try { var response = await DesignationService.UpdateDesignationAsync(_model); await Task.Delay(500); if (response != null && response.IsSuccess) { Snackbar.Add("Updated successfully", Severity.Success); await OnSuccess.InvokeAsync(); } } finally { _processing = false; } } }