Ejemplo n.º 1
0
 public async Task <PagedOdataResult <T> > GetResult(Uri requestUri, bool shouldAudit)
 {
     try
     {
         return(await GetInternalAsync(requestUri, shouldAudit));
     }
     catch (UnauthorizedAccessException)
     {
         logger.Info($"Access denined, access token expired - will retry with new token - '{requestUri}'.");
         tokenClient.SetAccessToken(string.Empty);
         return(await GetInternalAsync(requestUri, shouldAudit));
     }
 }
        public async Task ExecuteAsync(ProjectedVacancyDetails myQueueItem)
        {
            List <PublishedAV> publishedVacancies = new List <PublishedAV>();

            sitefinityTokenClient.SetAccessToken(myQueueItem.AccessToken);
            await apprenticeshipVacancyRepository.DeleteExistingAsync(myQueueItem.SocCode);

            logger.Info($"Deleted all vacancies for soc code {myQueueItem.SocCode}, ready for publishing {myQueueItem.Vacancies.Count()} vacancies.");

            foreach (var vacancy in myQueueItem.Vacancies)
            {
                var urlName = await apprenticeshipVacancyRepository.PublishAsync(vacancy, myQueueItem.SocMappingId);

                publishedVacancies.Add(new PublishedAV
                {
                    UrlName          = urlName,
                    VacancyReference = vacancy.VacancyReference,
                    Title            = vacancy.Title,
                    VacancyUrl       = vacancy.VacancyUrl
                });
            }

            output = new PublishedVacancySummary
            {
                SocCode      = myQueueItem.SocCode,
                SocMappingId = myQueueItem.SocMappingId,
                Vacancies    = publishedVacancies,
            };
        }