private bool ProcessApprenticeshipApplication(ApplicationStatusSummary applicationStatusSummary) { var apprenticeshipApplicationDetail = default(ApprenticeshipApplicationDetail); if (applicationStatusSummary.ApplicationId != Guid.Empty) { apprenticeshipApplicationDetail = _apprenticeshipApplicationReadRepository.Get(applicationStatusSummary.ApplicationId); } if (apprenticeshipApplicationDetail == null && applicationStatusSummary.LegacyApplicationId != 0) { apprenticeshipApplicationDetail = _apprenticeshipApplicationReadRepository.Get(applicationStatusSummary.LegacyApplicationId); } if (apprenticeshipApplicationDetail == null && applicationStatusSummary.LegacyCandidateId != 0) { // in some cases the application can't be found using the application IDs so use legacy candidate and vacancy IDs var candidate = _candidateReadRepository.Get(applicationStatusSummary.LegacyCandidateId); apprenticeshipApplicationDetail = _apprenticeshipApplicationReadRepository.GetForCandidate(candidate.EntityId, applicationStatusSummary.LegacyVacancyId); } if (apprenticeshipApplicationDetail == null) { return(false); // not necessarily an error as may be a traineeship } _applicationStatusUpdateStrategy.Update(apprenticeshipApplicationDetail, applicationStatusSummary); return(true); }
private void SetDecision(Guid applicationId, ApplicationStatuses applicationStatus, string candidateApplicationFeedback = null) { var apprenticeshipApplication = _apprenticeshipApplicationReadRepository.Get(applicationId); var legacyApplicationId = apprenticeshipApplication.LegacyApplicationId; if (legacyApplicationId == 0) { legacyApplicationId = _referenceNumberRepository.GetNextLegacyApplicationId(); } var applicationStatusSummary = new ApplicationStatusSummary { // CRITICAL: make the update look like it came from legacy AVMS application ApplicationId = Guid.Empty, ApplicationStatus = applicationStatus, LegacyApplicationId = legacyApplicationId, LegacyCandidateId = 0, // not required LegacyVacancyId = 0, // not required VacancyStatus = apprenticeshipApplication.VacancyStatus, ClosingDate = apprenticeshipApplication.Vacancy.ClosingDate, UpdateSource = ApplicationStatusSummary.Source.Raa //Ensure this update is from RAA so ownership of the application is verified }; if (candidateApplicationFeedback != null) { applicationStatusSummary.UnsuccessfulReason = candidateApplicationFeedback; } _applicationStatusUpdateStrategy.Update(apprenticeshipApplication, applicationStatusSummary); _serviceBus.PublishMessage(new ApprenticeshipApplicationUpdate(applicationId, ApplicationUpdateType.Update)); }
public void Update(Candidate candidate, IEnumerable <ApplicationStatusSummary> applicationStatuses) { // For the specified candidate, update the application repo for any of the status updates // passed in (if they're different). foreach (var applicationStatusSummary in applicationStatuses) { var legacyVacancyId = applicationStatusSummary.LegacyVacancyId; // Try apprenticeships first, the majority should be apprenticeships var apprenticeshipApplication = _apprenticeshipApplicationReadRepository.GetForCandidate(candidate.EntityId, legacyVacancyId); if (apprenticeshipApplication != null) { _applicationStatusUpdateStrategy.Update(apprenticeshipApplication, applicationStatusSummary); continue; } var traineeshipApplication = _traineeshipApplicationReadRepository.GetForCandidate(candidate.EntityId, legacyVacancyId); if (traineeshipApplication != null) { if (traineeshipApplication.UpdateTraineeshipApplicationDetail(applicationStatusSummary)) { _traineeshipApplicationWriteRepository.Save(traineeshipApplication); } continue; } _logger.Warn("Unable to find apprenticeship or traineeship application with legacy ID \"{0}\".", applicationStatusSummary.LegacyApplicationId); } }