Пример #1
0
        private void RegisterDelegate(DelegateTableRow delegateRow, DateTime?welcomeEmailDate, int centreId)
        {
            var model = new DelegateRegistrationModel(delegateRow, centreId, welcomeEmailDate);
            var errorCodeOrCandidateNumber = registrationDataService.RegisterDelegate(model);

            switch (errorCodeOrCandidateNumber)
            {
            case "-1":
                delegateRow.Error = BulkUploadResult.ErrorReason.UnexpectedErrorForCreate;
                break;

            case "-2":
            case "-3":
            case "-4":
                throw new ArgumentOutOfRangeException(
                          nameof(errorCodeOrCandidateNumber),
                          errorCodeOrCandidateNumber,
                          "Unknown return value when creating delegate record."
                          );

            default:
                var newDelegateRecord =
                    userDataService.GetDelegateUserByCandidateNumber(errorCodeOrCandidateNumber, centreId) !;
                UpdateUserProfessionalRegistrationNumberIfNecessary(
                    delegateRow.HasPrn,
                    delegateRow.Prn,
                    newDelegateRecord.Id
                    );
                SetUpSupervisorDelegateRelations(delegateRow.Email !, centreId, newDelegateRecord.Id);
                if (welcomeEmailDate.HasValue)
                {
                    passwordResetService.GenerateAndScheduleDelegateWelcomeEmail(
                        delegateRow.Email !,
                        newDelegateRecord.CandidateNumber,
                        configuration.GetAppRootPath(),
                        welcomeEmailDate.Value,
                        "DelegateBulkUpload_Refactor"
                        );
                }

                delegateRow.RowStatus = RowStatus.Registered;
                break;
            }
        }
Пример #2
0
        public void Setup()
        {
            registrationDataService = A.Fake <IRegistrationDataService>();
            passwordDataService     = A.Fake <IPasswordDataService>();
            passwordResetService    = A.Fake <IPasswordResetService>();
            emailService            = A.Fake <IEmailService>();
            centresDataService      = A.Fake <ICentresDataService>();
            config = A.Fake <IConfiguration>();
            supervisorDelegateService    = A.Fake <ISupervisorDelegateService>();
            frameworkNotificationService = A.Fake <IFrameworkNotificationService>();
            userDataService = A.Fake <IUserDataService>();

            A.CallTo(() => config["CurrentSystemBaseUrl"]).Returns(OldSystemBaseUrl);
            A.CallTo(() => config["AppRootPath"]).Returns(RefactoredSystemBaseUrl);

            A.CallTo(() => centresDataService.GetCentreIpPrefixes(RegistrationModelTestHelper.Centre))
            .Returns(new[] { ApprovedIpPrefix });
            A.CallTo(() => centresDataService.GetCentreManagerDetails(A <int> ._))
            .Returns(("Test", "Approver", ApproverEmail));

            A.CallTo(() => registrationDataService.RegisterDelegate(A <DelegateRegistrationModel> ._))
            .Returns(NewCandidateNumber);

            registrationService = new RegistrationService(
                registrationDataService,
                passwordDataService,
                passwordResetService,
                emailService,
                centresDataService,
                config,
                supervisorDelegateService,
                frameworkNotificationService,
                userDataService,
                new NullLogger <RegistrationService>()
                );
        }
Пример #3
0
        public void Registering_delegate_with_approved_IP_registers_delegate_as_approved()
        {
            // Given
            const string clientIp = ApprovedIpPrefix + ".100";
            var          model    = RegistrationModelTestHelper.GetDefaultDelegateRegistrationModel();

            // When
            var(_, approved) = registrationService.RegisterDelegate(
                model,
                clientIp,
                false
                );

            // Then
            A.CallTo(
                () =>
                registrationDataService.RegisterDelegate(
                    A <DelegateRegistrationModel> .That.Matches(d => d.Approved)
                    )
                )
            .MustHaveHappened();
            Assert.That(approved);
        }