Beispiel #1
0
        private void CreateCandidate(CreateCandidateRequest request)
        {
            try
            {
                _logger.Debug("Creating candidate Id: {0}", request.CandidateId);

                var user = _userReadRepository.Get(request.CandidateId);
                user.AssertState("Create legacy user", UserStatuses.Active, UserStatuses.Locked);

                var candidate = _candidateReadRepository.Get(request.CandidateId, true);
                if (candidate.LegacyCandidateId == 0)
                {
                    _logger.Info("Sending request to create candidate in legacy system: Candidate Id: \"{0}\"", request.CandidateId);
                    var legacyCandidateId = _legacyCandidateProvider.CreateCandidate(candidate);
                    candidate.LegacyCandidateId = legacyCandidateId;
                    _candidateWriteRepository.Save(candidate);
                    _logger.Info("Candidate created in legacy system: Candidate Id: \"{0}\", Legacy Candidate Id: \"{1}\"", request.CandidateId, legacyCandidateId);
                }
                else
                {
                    _logger.Warn("User has already been activated in legacy system: Candidate Id: \"{0}\"", request.CandidateId);
                }
            }
            catch (Exception ex)
            {
                _logger.Error(string.Format("Create candidate with id {0} request async process failed", request.CandidateId), ex);
                Requeue(request);
            }
        }
Beispiel #2
0
        public void ShouldCreateCandidateUsingLegacyCandidateProvider()
        {
            var candidate = new Candidate
            {
                EntityId            = Guid.NewGuid(),
                RegistrationDetails = new RegistrationDetails
                {
                    FirstName    = "FirstName",
                    LastName     = "LastName",
                    EmailAddress = string.Format("nas.exemplar+{0}@gmail.com", Guid.NewGuid()),
                    DateOfBirth  = new DateTime(1980, 06, 15),
                    PhoneNumber  = "01221234567",
                    Address      = new Address
                    {
                        AddressLine1 = "103 Crawley Drive",
                        AddressLine3 = "Hemel Hempstead",
                        AddressLine4 = "Hertfordhsire",
                        Postcode     = "HP2 6AL",
                        AddressLine2 = "Hemel Hempstead"
                    },
                }
            };

            var result = _legacyCandidateProvider.CreateCandidate(candidate);

            result.Should().BeGreaterThan(0);
        }
        private Candidate CreateCandidate()
        {
            // Create a new candidate in legacy and repo.
            var candidate = TestCandidateHelper.CreateFakeCandidate();

            candidate.LegacyCandidateId = _legacyCandidateProvider.CreateCandidate(candidate);

            return(candidate);
        }
Beispiel #4
0
        public void ActivateCandidate(string username, string activationCode)
        {
            var user = _userReadRepository.Get(username);

            user.AssertState("Activate user", UserStatuses.PendingActivation);

            var candidate = _candidateReadRepository.Get(user.EntityId);

            if (candidate.LegacyCandidateId == 0)
            {
                // Create candidate on legacy system before activating
                var legacyCandidateId = _legacyCandidateProvider.CreateCandidate(candidate);
                candidate.LegacyCandidateId = legacyCandidateId;
                _candidateWriteRepository.Save(candidate);
            }

            _registrationService.Activate(username, activationCode);
        }
        public void ResetForgottenPassword(string username, string passwordCode, string newPassword)
        {
            var user = _userReadRepository.Get(username);

            var candidate = _candidateReadRepository.Get(user.EntityId);

            if (candidate.LegacyCandidateId == 0)
            {
                // Candidate record does not exist on legacy system, create it now.
                var legacyCandidateId = _legacyCandidateProvider.CreateCandidate(candidate);

                candidate.LegacyCandidateId = legacyCandidateId;

                _candidateWriteRepository.Save(candidate);
            }

            _resetForgottenPasswordStrategy.ResetForgottenPassword(username, passwordCode, newPassword);
        }
        public void UnlockAccount(string username, string accountUnlockCode)
        {
            var user = _userReadRepository.Get(username);

            var candidate = _candidateReadRepository.Get(user.EntityId);

            user.AssertState("Unlock account", UserStatuses.Locked);

            if (candidate.LegacyCandidateId > 0)
            {
                _unlockAccountStrategy.UnlockAccount(username, accountUnlockCode);
            }
            else
            {
                // Create candidate on legacy system and unlock account
                var legacyCandidateId = _legacyCandidateProvider.CreateCandidate(candidate);
                candidate.LegacyCandidateId = legacyCandidateId;
                _candidateWriteRepository.Save(candidate);
                _unlockAccountStrategy.UnlockAccount(username, accountUnlockCode);
            }
        }
        private int CreateLegacyCandidateId()
        {
            var candidate = TestCandidateHelper.CreateFakeCandidate();

            return(_legacyCandidateProvider.CreateCandidate(candidate));
        }