예제 #1
0
        public async Task Handle(PatchVacancyTrainingProviderCommand message, CancellationToken cancellationToken)
        {
            var vacancy = await _repository.GetVacancyAsync(message.VacancyId);

            if (vacancy.OwnerType == OwnerType.Employer)
            {
                _logger.LogInformation("Vacancy: {vacancyId} already is employer owned so will not backfill provider info.", vacancy.Id);
                return;
            }

            if (!string.IsNullOrEmpty(vacancy.TrainingProvider.Name))
            {
                _logger.LogInformation("Vacancy: {vacancyId} already has training provider info backfilled. Will not be changed.", vacancy.Id);
                return;
            }

            _logger.LogInformation("Patching training provider name and address for vacancy {vacancyId}.", message.VacancyId);

            var tp = await _trainingProviderService.GetProviderAsync(vacancy.TrainingProvider.Ukprn.Value);

            vacancy = await _repository.GetVacancyAsync(message.VacancyId);

            PatchVacancyTrainingProvider(vacancy, tp);

            await _repository.UpdateAsync(vacancy);

            _logger.LogInformation("Updated Vacancy: {vacancyId} with training provider name and address", vacancy.Id);
        }
        public async Task <IEnumerable <CommunicationUser> > GetParticipantsAsync(CommunicationRequest request)
        {
            _logger.LogDebug($"Resolving participants for RequestType: '{request.RequestType}'");

            var entityId = request.Entities.Single(e => e.EntityType == CommunicationConstants.EntityTypes.Vacancy).EntityId.ToString();

            if (long.TryParse(entityId, out var vacancyReference) == false)
            {
                return(Array.Empty <CommunicationUser>());
            }

            var vacancy = await _vacancyRepository.GetVacancyAsync(vacancyReference);

            List <User> users = null;

            if (vacancy.OwnerType == OwnerType.Employer)
            {
                users = await _userRepository.GetEmployerUsersAsync(vacancy.EmployerAccountId);
            }
            else
            {
                users = await _userRepository.GetProviderUsersAsync(vacancy.TrainingProvider.Ukprn.GetValueOrDefault());
            }

            var primaryUserIdamsId = vacancy.Status == VacancyStatus.Rejected ? vacancy.ReviewByUser?.UserId : vacancy.SubmittedByUser?.UserId;

            return(ParticipantResolverPluginHelper.ConvertToCommunicationUsers(users, primaryUserIdamsId));
        }
예제 #3
0
        public async Task CloseExpiredVacancy(Guid vacancyId)
        {
            _logger.LogInformation("Closing vacancy {vacancyId}.", vacancyId);

            var vacancy = await _vacancyRepository.GetVacancyAsync(vacancyId);

            await CloseVacancyAsync(vacancy);
        }
        public async Task Handle(VacancyTransferredEvent notification, CancellationToken cancellationToken)
        {
            if (notification == null)
            {
                throw new ArgumentNullException(nameof(notification), "Should not be null");
            }

            var vacancy = await _vacancyRepository.GetVacancyAsync(notification.VacancyReference);

            _logger.LogInformation("Handling {eventType} for ukprn: {ukprn} and vacancyReference: {vacancyReference}", notification.GetType().Name, vacancy.TrainingProvider.Ukprn.Value, notification.VacancyReference);
            await _dashboardService.ReBuildDashboardAsync(vacancy.TrainingProvider.Ukprn.GetValueOrDefault());
        }
        public async Task Handle(VacancyTransferredEvent notification, CancellationToken cancellationToken)
        {
            if (notification == null)
            {
                throw new ArgumentNullException(nameof(notification), "Should not be null");
            }

            var vacancy = await _vacancyRepository.GetVacancyAsync(notification.VacancyReference);

            _logger.LogInformation("Handling {eventType} for accountId: {employerAccountId} and vacancyReference: {vacancyReference}", notification.GetType().Name, vacancy.EmployerAccountId, notification.VacancyReference);
            await _dashboardService.ReBuildDashboardAsync(vacancy.EmployerAccountId);
        }
예제 #6
0
        private async Task Handle(IApplicationReviewEvent notification)
        {
            if (notification == null)
            {
                throw new ArgumentNullException(nameof(notification), "Should not be null");
            }

            var vacancy = await _vacancyRepository.GetVacancyAsync(notification.VacancyReference);

            if (vacancy.OwnerType != OwnerType.Employer)
            {
                _logger.LogInformation("Handling {eventType} for ukprn: {ukprn} and vacancyReference: {vacancyReference}", notification.GetType().Name, vacancy.TrainingProvider.Ukprn.Value, notification.VacancyReference);
                await _dashboardService.ReBuildDashboardAsync(vacancy.TrainingProvider.Ukprn.Value);
            }
        }
        public async Task Handle(SubmitVacancyCommand message, CancellationToken cancellationToken)
        {
            _logger.LogInformation("Submitting vacancy {vacancyId}.", message.VacancyId);

            var vacancy = await _vacancyRepository.GetVacancyAsync(message.VacancyId);

            if (vacancy == null || vacancy.CanSubmit == false)
            {
                _logger.LogWarning($"Unable to submit vacancy {{vacancyId}} due to vacancy having a status of {vacancy?.Status}.", message.VacancyId);
                return;
            }

            var now = _timeProvider.Now;

            vacancy.EmployerDescription = message.EmployerDescription;
            vacancy.Status            = VacancyStatus.Submitted;
            vacancy.SubmittedDate     = now;
            vacancy.SubmittedByUser   = message.User;
            vacancy.LastUpdatedDate   = now;
            vacancy.LastUpdatedByUser = message.User;

            if (vacancy.VacancyReference.HasValue == false)
            {
                throw new Exception("Cannot submit vacancy without a vacancy reference");
            }

            await _vacancyRepository.UpdateAsync(vacancy);

            await _messaging.PublishEvent(new VacancySubmittedEvent
            {
                EmployerAccountId = vacancy.EmployerAccountId,
                VacancyId         = vacancy.Id,
                VacancyReference  = vacancy.VacancyReference.Value
            });
        }
예제 #8
0
        public async Task<Unit> Handle(ResetSubmittedVacancyCommand message, CancellationToken cancellationToken)
        {
            var vacancy = await _vacancyRepository.GetVacancyAsync(message.VacancyId);
            if (vacancy.Status != VacancyStatus.Submitted)
            {
                _logger.LogInformation($"No reviews will be updated for the vacancy {vacancy.VacancyReference} as it is in status {vacancy.Status}");
                return Unit.Value;
            }

            var review = await _vacancyReviewQuery.GetLatestReviewByReferenceAsync(vacancy.VacancyReference.GetValueOrDefault());

            if (review == null || review.Status == ReviewStatus.Closed)
            {
                _logger.LogInformation($"No active reviews found for vacancy {vacancy.VacancyReference}");
                return Unit.Value;
            }

            if (review.Status == ReviewStatus.UnderReview)
            {
                _logger.LogInformation($"The vacancy will not be updated {vacancy.VacancyReference} as it is being reviewed {review.Id}.");
                return Unit.Value;
            }
            else if (review.IsPending)
            {
                await ClosePendingReview(review);
                await UpdateVacancyStatusToDraft(vacancy);
                await _messaging.PublishEvent(
                    new VacancyReviewWithdrawnEvent(vacancy.Id, vacancy.VacancyReference.GetValueOrDefault(), review.Id));
            }
            
            return Unit.Value;
        }
예제 #9
0
        public async Task <Unit> Handle(CloseVacancyCommand message, CancellationToken cancellationToken)
        {
            var vacancy = await _vacancyRepository.GetVacancyAsync(message.VacancyId);

            if (vacancy == null || vacancy.Status != VacancyStatus.Live)
            {
                _logger.LogInformation($"Cannot close vacancy {message.VacancyId} as it was not found or is not in status live.");
            }

            _logger.LogInformation("Closing vacancy {vacancyId} by user {userEmail}.", vacancy.Id, message.User.Email);
            vacancy.ClosedByUser  = message.User;
            vacancy.ClosureReason = message.ClosureReason;

            vacancy.ClosedDate = _timeProvider.Now;
            vacancy.Status     = VacancyStatus.Closed;

            await _vacancyRepository.UpdateAsync(vacancy);

            await _messaging.PublishEvent(new VacancyClosedEvent
            {
                VacancyReference = vacancy.VacancyReference.GetValueOrDefault(),
                VacancyId        = vacancy.Id
            });

            return(Unit.Value);
        }
        public async Task Handle(VacancyClosedEvent notification, CancellationToken cancellationToken)
        {
            var vacancy = await _vacancyRepository.GetVacancyAsync(notification.VacancyId);

            try
            {
                if (vacancy.ClosureReason == ClosureReason.Manual)
                {
                    await _vacancyStatusNotifier.VacancyManuallyClosed(vacancy);
                }
            }
            catch (NotificationException ex)
            {
                _logger.LogError(ex, $"Unable to send notifications for {nameof(VacancyClosedEvent)} and VacancyReference: {{vacancyReference}}", notification.VacancyReference);
            }
        }
예제 #11
0
        public async Task <Unit> Handle(GeocodeVacancyCommand message, CancellationToken cancellationToken)
        {
            _logger.LogInformation("Geocoding vacancy {vacancyId}.", message.VacancyId);

            var vacancy = await _repository.GetVacancyAsync(message.VacancyId);

            if (string.IsNullOrEmpty(vacancy?.EmployerLocation?.Postcode))
            {
                _logger.LogWarning("Geocode vacancyId:{vacancyId} cannot geocode as vacancy has no postcode", vacancy.Id);
                return(Unit.Value);
            }

            var geocode = await GetGeocode(vacancy, vacancy.GeocodeUsingOutcode);

            if (geocode != null)
            {
                await SetVacancyGeocode(vacancy, geocode);
            }
            else
            {
                _logger.LogWarning($"Unable to get geocode information for postcode: {vacancy.EmployerLocation.Postcode}");
            }

            return(Unit.Value);
        }
        public async Task Handle(CreateVacancyReviewCommand message, CancellationToken cancellationToken)
        {
            _logger.LogInformation("Creating vacancy review for vacancy {vacancyReference}.", message.VacancyReference);

            var vacancyTask         = _vacancyRepository.GetVacancyAsync(message.VacancyReference);
            var previousReviewsTask = _vacancyReviewQuery.GetForVacancyAsync(message.VacancyReference);

            await Task.WhenAll(vacancyTask, previousReviewsTask);

            var vacancy         = vacancyTask.Result;
            var previousReviews = previousReviewsTask.Result;

            //Defensive code, just in case the message is republished due to an error after creating the review.
            var activePreviousReview = previousReviews.FirstOrDefault(r => r.Status != ReviewStatus.Closed);

            if (activePreviousReview != null)
            {
                _logger.LogWarning($"Cannot create review for vacancy {message.VacancyReference} as an active review {activePreviousReview.Id} already exists.");
                return;
            }

            var slaDeadline = await _slaService.GetSlaDeadlineAsync(vacancy.SubmittedDate.Value);

            var updatedFields = GetUpdatedFields(vacancy, previousReviews);

            var review = BuildNewReview(vacancy, previousReviews.Count, slaDeadline, updatedFields);

            await _vacancyReviewRepository.CreateAsync(review);

            await _messaging.PublishEvent(new VacancyReviewCreatedEvent
            {
                VacancyReference = message.VacancyReference,
                ReviewId         = review.Id
            });
        }
        public async Task <Unit> Handle(RejectVacancyCommand message, CancellationToken cancellationToken)
        {
            _logger.LogInformation("Rejecting vacancy {vacancyReference}.", message.VacancyReference);

            var vacancy = await _repository.GetVacancyAsync(message.VacancyReference);

            if (!vacancy.CanReview)
            {
                _logger.LogWarning($"Unable to refer vacancy {{vacancyReference}} due to vacancy having a status of {vacancy.Status}.", vacancy.VacancyReference);
                return(Unit.Value);
            }

            vacancy.Status = VacancyStatus.Rejected;

            await _repository.UpdateAsync(vacancy);

            await _messaging.PublishEvent(new VacancyRejectedEvent
            {
                ProviderUkprn    = vacancy.TrainingProvider.Ukprn,
                VacancyReference = vacancy.VacancyReference.Value,
                VacancyId        = vacancy.Id
            });

            return(Unit.Value);
        }
        public async Task <Unit> Handle(ApproveVacancyCommand message, CancellationToken cancellationToken)
        {
            _logger.LogInformation("Approving vacancy {vacancyReference}.", message.VacancyReference);

            var vacancy = await _repository.GetVacancyAsync(message.VacancyReference);

            if (!vacancy.CanApprove)
            {
                _logger.LogWarning($"Unable to approve vacancy {{vacancyReference}} due to vacancy having a status of {vacancy.Status}.", vacancy.VacancyReference);
                return(Unit.Value);
            }

            vacancy.Status       = VacancyStatus.Approved;
            vacancy.ApprovedDate = _timeProvider.Now;

            await _repository.UpdateAsync(vacancy);

            await _messaging.PublishEvent(new VacancyApprovedEvent
            {
                VacancyReference = vacancy.VacancyReference.Value,
                VacancyId        = vacancy.Id
            });

            return(Unit.Value);
        }
예제 #15
0
        public async Task Handle(TransferProviderVacancyCommand message, CancellationToken cancellationToken)
        {
            var vacancy = await _vacancyRepository.GetVacancyAsync(message.VacancyId);

            if (vacancy.OwnerType == OwnerType.Employer)
            {
                _logger.LogInformation($"Cannot transfer vacancy {vacancy.VacancyReference} as it is owned by {vacancy.OwnerType}.");
                return;
            }

            _logger.LogInformation($"Transferring the vacancy {vacancy.VacancyReference} to the employer as the provider {vacancy.TrainingProvider.Ukprn} is blocked");

            vacancy.TransferInfo = new TransferInfo()
            {
                Ukprn             = vacancy.TrainingProvider.Ukprn.GetValueOrDefault(),
                ProviderName      = vacancy.TrainingProvider.Name,
                LegalEntityName   = vacancy.LegalEntityName,
                TransferredByUser = message.TransferredByUser,
                TransferredDate   = message.TransferredDate,
                Reason            = message.Reason
            };
            vacancy.OwnerType = OwnerType.Employer;

            await _vacancyRepository.UpdateAsync(vacancy);

            await _messaging.PublishEvent(new VacancyTransferredEvent
            {
                VacancyId        = vacancy.Id,
                VacancyReference = vacancy.VacancyReference.GetValueOrDefault()
            });
        }
        private async Task Handle(Guid applicationReviewId, VacancyUser user, ApplicationReviewStatus status, string candidateFeedback = null)
        {
            var applicationReview = await _applicationReviewRepository.GetAsync(applicationReviewId);

            if (applicationReview.CanReview == false)
            {
                _logger.LogWarning("Cannot review ApplicationReviewId:{applicationReviewId} as not in correct state", applicationReview.Id);
                return;
            }

            var vacancy = await _vacancyRepository.GetVacancyAsync(applicationReview.VacancyReference);

            applicationReview.Status            = status;
            applicationReview.CandidateFeedback = candidateFeedback;
            applicationReview.StatusUpdatedDate = _timeProvider.Now;
            applicationReview.StatusUpdatedBy   = user;

            Validate(applicationReview);

            await _applicationReviewRepository.UpdateAsync(applicationReview);

            await _messaging.PublishEvent(new ApplicationReviewedEvent
            {
                Status            = applicationReview.Status,
                VacancyReference  = applicationReview.VacancyReference,
                CandidateFeedback = applicationReview.CandidateFeedback,
                CandidateId       = applicationReview.CandidateId
            });
        }
        public async Task HandleAsync(string eventPayload)
        {
            var eventData = DeserializeEvent <ProviderBlockedOnVacancyEvent>(eventPayload);

            _logger.LogInformation($"Updating vacancy {eventData.VacancyId} as the provider {eventData.Ukprn} is blocked");

            var vacancy = await _vacancyRepository.GetVacancyAsync(eventData.VacancyId);

            var hasToBeTransferred = vacancy.OwnerType == Entities.OwnerType.Provider;

            if (hasToBeTransferred)
            {
                await _messaging.SendCommandAsync(
                    new TransferProviderVacancyCommand(
                        vacancy.Id,
                        eventData.QaVacancyUser,
                        eventData.BlockedDate,
                        Entities.TransferReason.BlockedByQa
                        ));
            }

            if (vacancy.Status == Entities.VacancyStatus.Submitted)
            {
                await _messaging.SendCommandAsync(new ResetSubmittedVacancyCommand(vacancy.Id));
            }

            if (vacancy.Status == Entities.VacancyStatus.Live)
            {
                var closureReason = hasToBeTransferred ? Entities.ClosureReason.TransferredByQa : Entities.ClosureReason.BlockedByQa;

                await _messaging.SendCommandAsync(new CloseVacancyCommand(vacancy.Id, eventData.QaVacancyUser, closureReason));
            }
        }
        public async Task <Unit> Handle(CreateApplicationReviewCommand message, CancellationToken cancellationToken)
        {
            _logger.LogInformation("Submitting application for vacancyId: {vacancyReference} for candidateId: {candidateId}", message.Application.VacancyReference, message.Application.CandidateId);

            var vacancy = await _vacancyRepository.GetVacancyAsync(message.Application.VacancyReference);

            var existingReview = await _applicationReviewRepository.GetAsync(vacancy.VacancyReference.Value, message.Application.CandidateId);

            if (existingReview != null)
            {
                _logger.LogWarning("Application review already exists for vacancyReference:{vacancyReference} and candidateId:{candidateId}. Found applicationReviewId:{applicationReviewId}",
                                   vacancy.VacancyReference.Value, message.Application.CandidateId, existingReview.Id);
                return(Unit.Value);
            }

            var review = new ApplicationReview
            {
                Id = Guid.NewGuid(),
                VacancyReference = vacancy.VacancyReference.Value,
                Application      = message.Application,
                CandidateId      = message.Application.CandidateId,
                CreatedDate      = _timeProvider.Now,
                Status           = ApplicationReviewStatus.New,
                SubmittedDate    = message.Application.ApplicationDate
            };

            await _applicationReviewRepository.CreateAsync(review);

            await _messaging.PublishEvent(new ApplicationReviewCreatedEvent
            {
                VacancyReference = vacancy.VacancyReference.Value
            });

            return(Unit.Value);
        }
        public async Task Handle(DeleteVacancyCommand message, CancellationToken cancellationToken)
        {
            _logger.LogInformation("Deleting vacancy {vacancyId}", message.VacancyId);

            var vacancy = await _repository.GetVacancyAsync(message.VacancyId);

            if (vacancy == null || vacancy.CanDelete == false)
            {
                _logger.LogWarning($"Unable to delete vacancy {{vacancyId}} due to vacancy having a status of {vacancy?.Status}.", message.VacancyId);
                return;
            }

            var now = _timeProvider.Now;

            vacancy.IsDeleted         = true;
            vacancy.DeletedDate       = now;
            vacancy.DeletedByUser     = message.User;
            vacancy.LastUpdatedDate   = now;
            vacancy.LastUpdatedByUser = message.User;

            await _repository.UpdateAsync(vacancy);

            await _messaging.PublishEvent(new VacancyDeletedEvent
            {
                VacancyId = vacancy.Id
            });
        }
        public async Task <Unit> Handle(AssignVacancyNumberCommand message, CancellationToken cancellationToken)
        {
            var vacancy = await _repository.GetVacancyAsync(message.VacancyId);

            if (vacancy.VacancyReference.HasValue)
            {
                _logger.LogInformation("Vacancy: {vacancyId} already has a vacancy number: {vacancyNumber}. Will not be changed.", vacancy.Id, vacancy.VacancyReference);
                return(Unit.Value);
            }

            _logger.LogInformation("Assigning vacancy number for vacancy {vacancyId}.", message.VacancyId);

            vacancy.VacancyReference = await _generator.GenerateAsync();

            await _repository.UpdateAsync(vacancy);

            await _messaging.PublishEvent(new DraftVacancyUpdatedEvent
            {
                EmployerAccountId = vacancy.EmployerAccountId,
                VacancyId         = vacancy.Id
            });

            _logger.LogInformation("Updated Vacancy: {vacancyId} with vacancy number: {vacancyNumber}", vacancy.Id, vacancy.VacancyReference);
            return(Unit.Value);
        }
        public async Task Handle(GeocodeVacancyCommand message, CancellationToken cancellationToken)
        {
            _logger.LogInformation("Geocoding vacancy {vacancyId}.", message.VacancyId);

            var vacancy = await _repository.GetVacancyAsync(message.VacancyId);

            if (string.IsNullOrEmpty(vacancy?.EmployerLocation?.Postcode))
            {
                _logger.LogWarning("Geocode vacancyId:{vacancyId} cannot geocode as vacancy has no postcode", vacancy.Id);
                return;
            }

            _logger.LogInformation("Attempting to geocode postcode:{postcode} for vacancyId:{vacancyId}", vacancy.EmployerLocation.Postcode, vacancy.Id);
            var geocode = await _geocodeService.Geocode(vacancy.EmployerLocation.Postcode);

            await SetVacancyGeocode(vacancy.Id, geocode);
        }
        public async Task Run(long vacancyReference, Guid userRef, string userEmailAddress, string userName, TransferReason transferReason)
        {
            var vacancyToTransfer = await _vacancyRepository.GetVacancyAsync(vacancyReference);

            if (vacancyToTransfer != null)
            {
                await _messaging.SendCommandAsync(new TransferVacancyToLegalEntityCommand(vacancyToTransfer.VacancyReference.GetValueOrDefault(), userRef, userEmailAddress, userName, transferReason));
            }
        }
        public async Task Handle(GeocodeVacancyCommand message, CancellationToken cancellationToken)
        {
            _logger.LogInformation("Geocoding vacancy {vacancyId}.", message.VacancyId);

            var vacancy = await _repository.GetVacancyAsync(message.VacancyId);

            if (string.IsNullOrEmpty(vacancy?.EmployerLocation?.Postcode))
            {
                _logger.LogWarning("Geocode vacancyId:{vacancyId} cannot geocode as vacancy has no postcode", vacancy.Id);
                return;
            }

            var geocode = vacancy.GeocodeUsingOutcode
                ? await GeocodeOutcodeAsync(vacancy)
                : await GeocodePostcodeAsync(vacancy);

            await SetVacancyGeocode(vacancy.Id, geocode);
        }
예제 #24
0
        public async Task <Unit> Handle(ReviewVacancyCommand message, CancellationToken cancellationToken)
        {
            _logger.LogInformation("Reviewing vacancy {vacancyId}.", message.VacancyId);

            var vacancy = await _vacancyRepository.GetVacancyAsync(message.VacancyId);

            if (vacancy == null)
            {
                throw new ArgumentException(string.Format(VacancyNotFoundExceptionMessageFormat, message.VacancyId));
            }

            if (vacancy.VacancyReference.HasValue == false)
            {
                throw new InvalidOperationException(string.Format(MissingReferenceNumberExceptionMessageFormat, vacancy.Id));
            }

            if (vacancy.CanSubmit == false)
            {
                throw new InvalidOperationException(string.Format(InvalidStateExceptionMessageFormat, vacancy.Id, vacancy.Status));
            }

            if (vacancy.OwnerType != message.SubmissionOwner)
            {
                throw new InvalidOperationException(string.Format(InvalidOwnerExceptionMessageFormat, vacancy.Id, message.SubmissionOwner, vacancy.OwnerType));
            }

            var now = _timeProvider.Now;

            if (!string.IsNullOrEmpty(message.EmployerDescription))
            {
                vacancy.EmployerDescription = message.EmployerDescription;
            }

            vacancy.EmployerName = await _employerService.GetEmployerNameAsync(vacancy);

            vacancy.Status = VacancyStatus.Review;
            vacancy.EmployerRejectedReason = null;
            vacancy.ReviewDate             = now;
            vacancy.ReviewCount           += 1;
            vacancy.ReviewByUser           = message.User;
            vacancy.LastUpdatedDate        = now;
            vacancy.LastUpdatedByUser      = message.User;

            await _vacancyRepository.UpdateAsync(vacancy);

            await _messaging.PublishEvent(new VacancyReviewedEvent
            {
                EmployerAccountId = vacancy.EmployerAccountId,
                VacancyId         = vacancy.Id,
                VacancyReference  = vacancy.VacancyReference.Value,
                Ukprn             = vacancy.TrainingProvider.Ukprn.GetValueOrDefault()
            });

            return(Unit.Value);
        }
예제 #25
0
        public async Task <IEnumerable <CommunicationDataItem> > GetDataItemsAsync(object entityId)
        {
            if (long.TryParse(entityId.ToString(), out var vacancyReference) == false)
            {
                throw new InvalidEntityIdException(EntityType, nameof(ApprenticeshipServiceUrlDataEntityPlugin));
            }

            var vacancy = await _vacancyRepository.GetVacancyAsync(vacancyReference);


            return(new [] { GetApplicationUrlDataItem(vacancy) });
        }
        private async Task CreateClosedVacancyProjection(Guid vacancyId)
        {
            var vacancyTask   = _repository.GetVacancyAsync(vacancyId);
            var programmeTask = _referenceDataReader.GetReferenceData <ApprenticeshipProgrammes>();

            await Task.WhenAll(vacancyTask, programmeTask);

            var vacancy   = vacancyTask.Result;
            var programme = programmeTask.Result.Data.Single(p => p.Id == vacancy.ProgrammeId);

            await _queryStore.UpdateClosedVacancyAsync(vacancy.ToVacancyProjectionBase <ClosedVacancy>(programme, () => QueryViewType.ClosedVacancy.GetIdValue(vacancy.VacancyReference.ToString())));
        }
        public async Task Handle(VacancyPublishedEvent notification, CancellationToken cancellationToken)
        {
            var vacancyTask   = _repository.GetVacancyAsync(notification.VacancyId);
            var programmeTask = _referenceDataReader.GetReferenceData <ApprenticeshipProgrammes>();

            await Task.WhenAll(vacancyTask, programmeTask);

            var vacancy   = vacancyTask.Result;
            var programme = programmeTask.Result.Data.Single(p => p.Id == vacancy.ProgrammeId);

            var liveVacancy = vacancy.ToVacancyProjectionBase <LiveVacancy>(programme, () => QueryViewType.LiveVacancy.GetIdValue(vacancy.VacancyReference.ToString()), _timeProvider);
            await _queryStoreWriter.UpdateLiveVacancyAsync(liveVacancy);
        }
        public async Task UpdateVacancyApplicationsAsync(long vacancyReference)
        {
            _logger.LogInformation("Updating vacancyApplications projection for vacancyReference: {vacancyReference}", vacancyReference);

            var vacancy = await _vacancyRepository.GetVacancyAsync(vacancyReference);

            var vacancyApplicationReviews = await _applicationReviewQuery.GetForVacancyAsync <ApplicationReview>(vacancy.VacancyReference.Value);

            var vacancyApplications = new VacancyApplications
            {
                VacancyReference = vacancy.VacancyReference.Value,
                Applications     = vacancyApplicationReviews.Select(MapToVacancyApplication).ToList()
            };

            await _writer.UpdateVacancyApplicationsAsync(vacancyApplications);
        }
        public async Task Handle(TransferVacancyToLegalEntityCommand message, CancellationToken cancellationToken)
        {
            var vacancy = await _vacancyRepository.GetVacancyAsync(message.VacancyReference);

            if (vacancy.OwnerType == OwnerType.Provider)
            {
                var vacancyUser = new VacancyUser
                {
                    UserId = message.UserRef.ToString(),
                    Email  = message.UserEmailAddress,
                    Name   = message.UserName
                };

                await ProcessTransferringVacancy(vacancy, vacancyUser, message.TransferReason);
            }
        }
예제 #30
0
        private async Task Handle(IApplicationReviewEvent notification)
        {
            _logger.LogInformation("Handling {notificationType} for vacancyReference: {vacancyReference}", notification.GetType().Name, notification?.VacancyReference);

            var vacancy = await _vacancyRepository.GetVacancyAsync(notification.VacancyReference);

            var vacancyApplicationReviews = await _applicationReviewQuery.GetForVacancyAsync <ApplicationReview>(vacancy.VacancyReference.Value);

            var vacancyApplications = new VacancyApplications
            {
                VacancyReference = vacancy.VacancyReference.Value,
                Applications     = vacancyApplicationReviews.Select(MapToVacancyApplication).ToList()
            };

            await _writer.UpdateVacancyApplicationsAsync(vacancyApplications);
        }