Ejemplo n.º 1
0
        private async Task CreateEmployeeAsync()
        {
            RenderFragment body = (builder) =>
            {
                builder.OpenComponent(0, typeof(CreateEmployee));
                builder.CloseComponent();
            };

            var instance = await ModalDialogService.ShowAsync("Create Employee", body, ModalDialogSize.Large);

            var result = await instance.Result;

            if (result.Succeeded)
            {
                await DataTableService.LoadTableDataAsync();

                await SynchronizationService.UpdateEmployees(PageId);
            }
        }
Ejemplo n.º 2
0
        private async Task EditEmployeeAsync()
        {
            RenderFragment body = (builder) =>
            {
                builder.OpenComponent(0, typeof(EditEmployee));
                builder.AddAttribute(1, nameof(EditEmployee.EmployeeId), DataTableService.SelectedEntity.Id);
                builder.CloseComponent();
            };

            var instance = await ModalDialogService.ShowAsync("Edit Employee", body);

            var result = await instance.Result;

            if (result.Succeeded)
            {
                await DataTableService.LoadTableDataAsync();

                await SynchronizationService.UpdateEmployees(PageId);
            }
        }
Ejemplo n.º 3
0
        public async Task DeleteEmployeeAsync()
        {
            try
            {
                await EmployeeService.DeleteEmployeeAsync(Employee.Id);

                await SynchronizationService.UpdateEmployees(ExceptPageId);

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

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

                await ModalDialogService.CancelAsync();
            }
        }
Ejemplo n.º 4
0
        private async Task SyncAsync()
        {
            try
            {
                await LdapService.SyncUsersAsync(LdapSettings);

                await LdapService.ChangePasswordWhenExpiredAsync(LdapSettings);

                await SynchronizationService.UpdateEmployees(ExceptPageId);

                await ToastService.ShowToastAsync("Users synced.", ToastType.Success);

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

                await ModalDialogService.CancelAsync();
            }
        }
Ejemplo n.º 5
0
        private async Task EditAsync()
        {
            try
            {
                await ButtonSpinner.SpinAsync(async() =>
                {
                    await EmployeeService.EditEmployeeAsync(Employee);
                    await ToastService.ShowToastAsync("Employee updated.", ToastType.Success);
                    await SynchronizationService.UpdateEmployees(ExceptPageId);
                    await ModalDialogService.CloseAsync();
                });
            }
            catch (AlreadyExistException ex)
            {
                ValidationErrorMessage.DisplayError(nameof(Employee.FirstName), ex.Message);
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);

                await ModalDialogService.CloseAsync();
            }
        }
Ejemplo n.º 6
0
        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 SynchronizationService.UpdateEmployees(ExceptPageId);

                    await ModalDialogService.CloseAsync();

                    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 SynchronizationService.UpdateEmployees(ExceptPageId);

                await ModalDialogService.CloseAsync();

                break;
            }
        }