コード例 #1
0
        public void ProcessApplicationStatuses(VacancyStatusSummary vacancyStatusSummary)
        {
            // propagate current vacancy state to all draft applications for the vacancy
            var applicationSummaries = _apprenticeshipApplicationReadRepository.GetApplicationSummaries(vacancyStatusSummary.LegacyVacancyId);

            var applicationStatusSummaries = applicationSummaries
                                             .Where(applicationSummary => applicationSummary.Status == ApplicationStatuses.Draft)
                                             .Select(applicationSummary =>
                                                     new ApplicationStatusSummary
            {
                ApplicationId        = applicationSummary.ApplicationId,
                ApplicationStatus    = applicationSummary.Status,
                LegacyApplicationId  = applicationSummary.LegacyApplicationId,
                LegacyVacancyId      = applicationSummary.LegacyVacancyId,
                VacancyStatus        = vacancyStatusSummary.VacancyStatus,
                ClosingDate          = vacancyStatusSummary.ClosingDate,
                UnsuccessfulReason   = applicationSummary.UnsuccessfulReason,
                UnsuccessfulDateTime = applicationSummary.UnsuccessfulDateTime
            });

            Parallel.ForEach(
                applicationStatusSummaries,
                new ParallelOptions {
                MaxDegreeOfParallelism = 5
            },
                applicationStatusSummary => _serviceBus.PublishMessage(applicationStatusSummary));
        }
コード例 #2
0
        public Task Consume(VacancyAboutToExpire vacancy)
        {
            return(Task.Run(() =>
            {
                //Get draft applications for expiring vacancy
                var expiringApplications =
                    _apprenticeshipApplicationReadRepository.GetApplicationSummaries(vacancy.Id)
                    .Where(v => v.Status == ApplicationStatuses.Draft);

                if (!expiringApplications.Any())
                {
                    return;
                }

                //Map to expiring draft model
                var expiringDrafts =
                    _mapper.Map <IEnumerable <ApprenticeshipApplicationSummary>, IEnumerable <ExpiringApprenticeshipApplicationDraft> >(
                        expiringApplications).ToList();

                //Get those already notified or marked for notification
                var alreadyExpiringDrafts = _expiringDraftRepository.GetExpiringApplications(vacancy.Id);

                //Get those that haven't been added to expiring repo
                var newExpiringDrafts = expiringDrafts.Where(e => !alreadyExpiringDrafts.Select(ev => ev.EntityId).Contains(e.EntityId)).ToList();

                //Write to repo
                newExpiringDrafts.ForEach(_expiringDraftRepository.Save);
            }));
        }
        public void GetApprenticeshipApplicationsReturnsCorrectResults()
        {
            //Arrange - Build Applications
            var applications = BuildApprenticeshipApplicationDetails();

            applications.ForEach(a => _apprenticeshipApplicationWriteRepository.Save(a));

            //Act - Get application vacancy statuses
            var summaries = _apprenticeshipApplicationReadRepository
                            .GetApplicationSummaries(TestVacancyId)
                            .ToList();

            //Assert - the correct number of applicaitons with the correct vacancy state
            summaries.Count(v => v.VacancyStatus == VacancyStatuses.Live).Should().Be(10);
            summaries.Count(v => v.VacancyStatus == VacancyStatuses.Unavailable).Should().Be(7);
            summaries.Count(v => v.VacancyStatus == VacancyStatuses.Expired).Should().Be(6);
        }
コード例 #4
0
 public IEnumerable <ApprenticeshipApplicationSummary> GetApplicationSummaries(int vacancyId)
 {
     return(_apprenticeshipApplicationReadRepository.GetApplicationSummaries(vacancyId));
 }