public Candidate SaveCandidate(Candidate candidate)
        {
            var result = _candidateWriteRepository.Save(candidate);

            _serviceBus.PublishMessage(new CandidateUserUpdate(candidate.EntityId, CandidateUserUpdateType.Update));
            var reloadedCandidate = _candidateReadRepository.Get(candidate.EntityId);

            var candidateApplications = _getCandidateApplicationsStrategy
                                        .GetApplications(candidate.EntityId)
                                        .Where(a => a.Status == ApplicationStatuses.Draft || a.Status == ApplicationStatuses.Saved)
                                        .ToList();

            candidateApplications.ForEach(candidateApplication =>
            {
                try
                {
                    UpdateApprenticeshipApplicationDetail(reloadedCandidate, candidateApplication.LegacyVacancyId);
                }
                catch (Exception e)
                {
                    // try updating the next one
                    var message = string.Format(
                        "Error while updating a draft application with the updated user personal details for user {0}",
                        candidate.EntityId);
                    _logger.Warn(message, e);
                }
            });

            return(result);
        }
        public IList <ApprenticeshipApplicationSummary> GetApprenticeshipApplications(Guid candidateId, bool refresh = true)
        {
            Condition.Requires(candidateId);

            _logger.Debug(
                "Calling CandidateService to get the apprenticeship applications of the user with Id={0}.",
                candidateId);

            return(_getCandidateApprenticeshipApplicationsStrategy.GetApplications(candidateId, refresh));
        }
Beispiel #3
0
        public Candidate SaveCandidate(Candidate candidate)
        {
            if (candidate.MobileVerificationRequired())
            {
                candidate.CommunicationPreferences.MobileVerificationCode = _codeGenerator.GenerateNumeric();
                _sendMobileVerificationCodeStrategy.SendMobileVerificationCode(candidate);
            }

            var result = _candidateWriteRepository.Save(candidate);

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

            var candidateApplications = _getCandidateApplicationsStrategy
                                        .GetApplications(candidate.EntityId)
                                        .Where(a => a.Status == ApplicationStatuses.Draft)
                                        .ToList();

            candidateApplications.ForEach(candidateApplication =>
            {
                try
                {
                    UpdateApprenticeshipApplicationDetail(reloadedCandidate, candidateApplication.LegacyVacancyId);
                }
                catch (Exception e)
                {
                    // try updating the next one
                    var message = string.Format(
                        "Error while updating a draft application with the updated user personal details for user {0}",
                        candidate.EntityId);

                    _logger.Warn(message, e);
                }
            });

            return(result);
        }