private async Task EditAsync() { try { await ButtonSpinner.SpinAsync(async() => { await OrgStructureService.EditDepartmentAsync(Department); await ToastService.ShowToastAsync("Department updated.", ToastType.Success); await Refresh.InvokeAsync(this); await SynchronizationService.UpdateOrgSructureCompanies(ExceptPageId); await ModalDialogService.CloseAsync(); }); } catch (AlreadyExistException ex) { ValidationErrorMessage.DisplayError(nameof(Department.Name), ex.Message); } catch (Exception ex) { Logger.LogError(ex.Message); await ToastService.ShowToastAsync(ex.Message, ToastType.Error); await ModalDialogService.CloseAsync(); } }
public async Task DeleteAsync() { try { await OrgStructureService.DeleteDepartmentAsync(Department.Id); await Refresh.InvokeAsync(this); await SynchronizationService.UpdateOrgSructureCompanies(ExceptPageId); await ToastService.ShowToastAsync("Department removed.", ToastType.Success); await ModalDialogService.CloseAsync(); } catch (Exception ex) { await ModalDialogService.CancelAsync(); Logger.LogError(ex.Message, ex); await ToastService.ShowToastAsync(ex.Message, ToastType.Error); } }