コード例 #1
0
        private Task Handle(IEmployerEvent notification)
        {
            if (notification == null)
            {
                throw new ArgumentNullException(nameof(notification), "Should not be null");
            }

            _logger.LogInformation("Handling {eventType} for accountId: {employerAccountId}", notification.GetType().Name, notification.EmployerAccountId);
            return(_dashboardService.ReBuildDashboardAsync(notification.EmployerAccountId));
        }
        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);
        }
コード例 #3
0
        public async Task ReGenerateSingleEmployerDashboard([QueueTrigger(QueueNames.GenerateSingleEmployerDashboardQueueName, Connection = "QueueStorage")] string message, TextWriter log)
        {
            const string individualJobName = "SingleEmployerDashboardGeneratorJob";

            if (_jobsConfig.DisabledJobs.Contains(individualJobName))
            {
                _logger.LogDebug($"{individualJobName} is disabled, skipping ...");
                return;
            }

            try
            {
                var data = JsonConvert.DeserializeObject <EmployerDashboardCreateMessage>(message);
                _logger.LogInformation($"Start {JobName} For Employer Account: {data.EmployerAccountId}");

                await _projectionService.ReBuildDashboardAsync(data.EmployerAccountId);

                _logger.LogInformation($"Finished {JobName} For Employer Account: {data.EmployerAccountId}");
            }
            catch (JsonException ex)
            {
                _logger.LogError(ex, "Unable to deserialise event: {eventBody}", message);
                throw;
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, $"Unable to run {JobName}.");
                throw;
            }
        }
コード例 #4
0
        public async Task <Unit> Handle(ApproveVacancyReviewCommand message, CancellationToken cancellationToken)
        {
            _logger.LogInformation("Approving review {reviewId}.", message.ReviewId);

            var review = await _vacancyReviewRepository.GetAsync(message.ReviewId);

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

            if (!review.CanApprove)
            {
                _logger.LogWarning($"Unable to approve review {{reviewId}} due to review having a status of {review.Status}.", message.ReviewId);
                return(Unit.Value);
            }

            review.ManualOutcome           = ManualQaOutcome.Approved;
            review.Status                  = ReviewStatus.Closed;
            review.ClosedDate              = _timeProvider.Now;
            review.ManualQaComment         = message.ManualQaComment;
            review.ManualQaFieldIndicators = message.ManualQaFieldIndicators;

            foreach (var automatedQaOutcomeIndicator in review.AutomatedQaOutcomeIndicators)
            {
                automatedQaOutcomeIndicator.IsReferred = message.SelectedAutomatedQaRuleOutcomeIds
                                                         .Contains(automatedQaOutcomeIndicator.RuleOutcomeId);
            }

            Validate(review);

            await _vacancyReviewRepository.UpdateAsync(review);

            var closureReason = await TryGetReasonToCloseVacancy(review, vacancy);

            if (closureReason != null)
            {
                await CloseVacancyAsync(vacancy, closureReason.Value);
                await SendNotificationToEmployerAsync(vacancy.TrainingProvider.Ukprn.GetValueOrDefault(), vacancy.EmployerAccountId);

                await _dashboardService.ReBuildDashboardAsync(vacancy.EmployerAccountId);

                return(Unit.Value);
            }

            await PublishVacancyReviewApprovedEventAsync(message, review);

            return(Unit.Value);
        }
コード例 #5
0
 public Task GenerateDashboard(string employerAccountId)
 {
     return(_employerDashboardService.ReBuildDashboardAsync(employerAccountId));
 }