Example #1
0
        public async Task DeleteVaultAsync()
        {
            try
            {
                var employeeId = HardwareVault.EmployeeId;
                await EmployeeService.RemoveHardwareVaultAsync(HardwareVault.Id, Reason, IsNeedBackup);

                await Refresh.InvokeAsync(this);

                RemoteDeviceConnectionsService.StartUpdateHardwareVaultStatus(HardwareVault.Id);
                await SynchronizationService.UpdateEmployeeDetails(ExceptPageId, employeeId);

                await SynchronizationService.HardwareVaultStateChanged(HardwareVault.Id);

                await ToastService.ShowToastAsync("Vault removed.", ToastType.Success);

                await ModalDialogService.CloseAsync();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message, ex);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);

                await ModalDialogService.CancelAsync();
            }
        }
        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);
            }
        }