Exemplo n.º 1
0
        private async Task ChangeStatusAsync()
        {
            try
            {
                switch (VaultStatus)
                {
                case VaultStatus.Active:
                    await HardwareVaultService.ActivateVaultAsync(HardwareVault.Id);

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

                    break;

                case VaultStatus.Suspended:
                    await HardwareVaultService.SuspendVaultAsync(HardwareVault.Id, StatusDescription);

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

                    break;

                case VaultStatus.Compromised:
                    if (CompromisedIsDisabled)
                    {
                        return;
                    }
                    await HardwareVaultService.VaultCompromisedAsync(HardwareVault.Id, StatusReason, StatusDescription);

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

                    break;
                }

                await SynchronizationService.UpdateHardwareVaults(ExceptPageId);

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

                await ModalDialogService.CancelAsync();
            }
        }