protected override async Task OnInitializedAsync() { try { HardwareVaultService = ScopedServices.GetRequiredService <IHardwareVaultService>(); InputType = "Password"; HardwareVault = await HardwareVaultService.GetVaultByIdAsync(HardwareVaultId); if (HardwareVault == null) { throw new Exception("HardwareVault not found."); } Code = await HardwareVaultService.GetVaultActivationCodeAsync(HardwareVault.Id); } catch (Exception ex) { Logger.LogError(ex.Message); await ToastService.ShowToastAsync(ex.Message, ToastType.Error); await ModalDialogService.CancelAsync(); } }
private async Task Next() { switch (WizardStep) { case WizardStep.Profile: var employeeNameExist = await EmployeeService.CheckEmployeeNameExistAsync(Employee); if (employeeNameExist) { EmployeeValidationErrorMessage.DisplayError(nameof(Core.Entities.Employee.FirstName), $"{Employee.FirstName} {Employee.LastName} already exists."); return; } var employeeIsValid = EmployeeContext.Validate(); if (!employeeIsValid) { return; } WizardStep = WizardStep.HardwareVault; break; case WizardStep.HardwareVault: if (SelectedHardwareVault == null) { WarningMessage = "Please, select a vault."; break; } WizardStep = WizardStep.WorkstationAccount; break; case WizardStep.WorkstationAccount: if (AccountType == AccountType.Personal) { var accountIsValid = PersonalAccountContext.Validate(); if (!accountIsValid) { return; } } WizardStep = WizardStep.Overview; break; case WizardStep.Overview: await CreateAsync(); if (SelectedHardwareVault == null) { await ToastService.ShowToastAsync("Employee created.", ToastType.Success); await ModalDialogClose(); break; } Code = await HardwareVaultService.GetVaultActivationCodeAsync(SelectedHardwareVault.Id); Email = Employee.Email; WizardStep = WizardStep.Activation; break; case WizardStep.Activation: await ToastService.ShowToastAsync("Employee created.", ToastType.Success); await ModalDialogClose(); break; } }