Пример #1
0
        public async Task HandleAsync(string eventPayload)
        {
            var eventData = DeserializeEvent <ProviderBlockedEvent>(eventPayload);

            _logger.LogInformation($"Begining to queue required updates after provider {eventData.Ukprn} was blocked");

            var tasks = new List <Task>();

            var providerInfoTask = _queryStoreReader.GetProviderVacancyDataAsync(eventData.Ukprn);
            var vacanciesTask    = _vacancyQuery.GetVacanciesAssociatedToProvider(eventData.Ukprn);
            await Task.WhenAll(providerInfoTask, vacanciesTask);

            var providerInfo = providerInfoTask.Result;
            var vacancies    = vacanciesTask.Result;

            if (providerInfo?.Employers != null)
            {
                tasks.AddRange(RaiseEventsToRevokePermission(providerInfo.Employers, eventData.Ukprn));
            }

            tasks.AddRange(RaiseEventsToUpdateVacancies(vacancies, eventData.QaVacancyUser, eventData.Ukprn, eventData.BlockedDate));

            tasks.Add(RequestProviderCommunicationAsync(eventData.Ukprn));

            tasks.AddRange(RequestEmployerCommunications(vacancies, providerInfo.Employers, eventData.Ukprn));

            await Task.WhenAll(tasks);

            _logger.LogInformation($"Finished queuing required updates after provider {eventData.Ukprn} was blocked");
        }
        public async Task <ConfirmTrainingProviderBlockingViewModel> GetConfirmTrainingProviderBlockingViewModelAsync(long ukprn)
        {
            var providerDetailTask          = _trainingProviderService.GetProviderAsync(ukprn);
            var providerEditVacancyInfoTask = _queryStore.GetProviderVacancyDataAsync(ukprn);
            await Task.WhenAll(providerEditVacancyInfoTask, providerDetailTask);

            var providerDetail      = providerDetailTask.Result;
            var providerVacancyInfo = providerEditVacancyInfoTask.Result;

            var permissionCount = 0;

            if (providerVacancyInfo?.Employers != null)
            {
                permissionCount = providerVacancyInfo.Employers.SelectMany(e => e.LegalEntities).Count();
            }

            return(ConvertToConfirmViewModel(providerDetail, permissionCount));
        }