Exemplo n.º 1
0
        public async Task HandleAsync(string eventPayload)
        {
            var eventData = DeserializeEvent <SetupProviderEvent>(eventPayload);

            try
            {
                _logger.LogInformation($"Processing {nameof(SetupProviderEvent)} for Ukprn: {{Ukprn}}", eventData.Ukprn);

                var employerInfosTask     = _providerRelationshipService.GetLegalEntitiesForProviderAsync(eventData.Ukprn);
                var providerAgreementTask = _pasAccountClient.HasAgreementAsync(eventData.Ukprn);

                await Task.WhenAll(employerInfosTask, providerAgreementTask);

                var employerInfos = employerInfosTask.Result;

                foreach (var employerInfo in employerInfos)
                {
                    await _client.SetupEmployerAsync(employerInfo.EmployerAccountId);
                }

                await _projectionService.UpdateProviderVacancyDataAsync(eventData.Ukprn, employerInfos, providerAgreementTask.Result);

                _logger.LogInformation($"Finished Processing {nameof(SetupProviderEvent)} for Ukprn: {{Ukprn}} has agreement:{providerAgreementTask.Result}", eventData.Ukprn);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Unable to process {eventBody}", eventData);
                throw;
            }
        }
Exemplo n.º 2
0
        public async Task <bool> HasAgreementAsync(long ukprn)
        {
            var editVacancyInfo = await _client.GetProviderEditVacancyInfoAsync(ukprn);

            if (editVacancyInfo == null)
            {
                return(false);
            }

            if (editVacancyInfo.HasProviderAgreement)
            {
                return(true);
            }

            //Agreement may have been signed since the projection was created. Check PAS.
            var hasAgreement = await _pasAccountClient.HasAgreementAsync(ukprn);

            if (hasAgreement)
            {
                await _client.SetupProviderAsync(ukprn);
            }

            return(hasAgreement);
        }
 public Task <bool> HasAgreementAsync(long ukprn)
 {
     return(_pasAccountClient.HasAgreementAsync(ukprn));
 }