private async Task AddVaultAsync() { try { if (SelectedHardwareVault == null) { WarningMessage = "Please, select a vault."; return; } using (TransactionScope transactionScope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) { await EmployeeService.AddHardwareVaultAsync(EmployeeId, SelectedHardwareVault.Id); var ldapSettings = await AppSettingsService.GetLdapSettingsAsync(); if (ldapSettings?.Password != null) { var employee = await EmployeeService.GetEmployeeByIdAsync(EmployeeId); if (employee.ActiveDirectoryGuid != null) { await LdapService.AddUserToHideezKeyOwnersAsync(ldapSettings, employee.ActiveDirectoryGuid); } } transactionScope.Complete(); } await Refresh.InvokeAsync(this); await ToastService.ShowToastAsync("Vault added", ToastType.Success); await SynchronizationService.UpdateEmployeeDetails(ExceptPageId, EmployeeId); await SynchronizationService.HardwareVaultStateChanged(SelectedHardwareVault.Id); await ModalDialogService.CloseAsync(); } catch (Exception ex) { await ModalDialogService.CloseAsync(); Logger.LogError(ex.Message, ex); await ToastService.ShowToastAsync(ex.Message, ToastType.Error); } }