public TraineeshipVacancyDetail GetVacancyDetails(int vacancyId, bool errorIfNotFound = false) { var vacancy = _vacancyReadRepository.Get(vacancyId); if (vacancy == null) { if (errorIfNotFound) { throw new DomainException(ErrorCodes.VacancyNotFoundError, new { vacancyId }); } return(null); } var vacancyOwnerRelationship = _providerService.GetVacancyOwnerRelationship(vacancy.VacancyOwnerRelationshipId, false); // Some current vacancies have non-current vacancy parties var employer = _employerService.GetEmployer(vacancyOwnerRelationship.EmployerId, false); var providerSite = _providerService.GetProviderSite(vacancyOwnerRelationship.ProviderSiteId); if (providerSite == null) { throw new System.Exception($"Could not find VacancyOwnerRelationship for ProviderSiteId={vacancyOwnerRelationship.ProviderSiteId}"); } var provider = _providerService.GetProvider(vacancy.ContractOwnerId); var categories = _referenceDataProvider.GetCategories(); return(TraineeshipVacancyDetailMapper.GetTraineeshipVacancyDetail(vacancy, employer, provider, providerSite, categories, _logService)); }
public VacancySummaries GetVacancySummaries(int pageNumber) { //Page number coming in increments from 1 rather than 0, the repo expects pages to start at 0 so take one from the passed in value var query = new VacancySummaryByStatusQuery() { PageSize = PageSize, RequestedPage = pageNumber, DesiredStatuses = _desiredStatuses }; int totalRecords; var vacancies = _vacancySummaryService.GetWithStatus(query, out totalRecords); var vacancyParties = _providerService.GetVacancyOwnerRelationships(vacancies.Select(v => v.VacancyOwnerRelationshipId).Distinct(), false); var employers = _employerService.GetEmployers(vacancyParties.Values.Select(v => v.EmployerId).Distinct()).ToDictionary(e => e.EmployerId, e => e); var providers = _providerService.GetProviders(vacancies.Select(v => v.ContractOwnerId).Distinct()).ToDictionary(p => p.ProviderId, p => p); var categories = _referenceDataProvider.GetCategories(CategoryStatus.Active, CategoryStatus.PendingClosure).ToList(); //TODO: workaround to have the indexing partially working. Should be done properly var apprenticeshipSummaries = vacancies.Where(v => v.VacancyType == VacancyType.Apprenticeship).Select( v => { try { return(ApprenticeshipSummaryMapper.GetApprenticeshipSummary(v, employers[vacancyParties[v.VacancyOwnerRelationshipId].EmployerId], providers[v.ContractOwnerId], categories, _logService)); } catch (Exception ex) { _logService.Error($"Error indexing the apprenticeship vacancy with ID={v.VacancyId}", ex); return(null); } }); var traineeshipSummaries = vacancies.Where(v => v.VacancyType == VacancyType.Traineeship).Select( v => { try { return(TraineeshipSummaryMapper.GetTraineeshipSummary(v, employers[vacancyParties[v.VacancyOwnerRelationshipId].EmployerId], providers[v.ContractOwnerId], categories, _logService)); } catch (Exception ex) { _logService.Error($"Error indexing the traineeship vacancy with ID={v.VacancyId}", ex); return(null); } }); return(new VacancySummaries(apprenticeshipSummaries.Where(s => s != null), traineeshipSummaries.Where(s => s != null))); }
public void Compare(List <Category> categories) { var existingCategories = _referenceDataProvider.GetCategories().ToList(); Console.WriteLine("EXISTING Vs NEW"); CompareCategories(existingCategories, categories); Console.WriteLine("NEW Vs EXISTING"); CompareCategories(categories, existingCategories); }
public void ReturnsCategoryDataFromFrameworksService() { var categories = _referenceDataProvider.GetCategories(); categories.Count().Should().BeGreaterThan(0); foreach (Category category in categories) { category.SubCategories.Count().Should().BeGreaterThan(0); } }
public void PublishVacancySummaryUpdate(Vacancy vacancy) { if (vacancy == null) { return; } try { if (vacancy.Status == VacancyStatus.Live) { var vacancySummary = _vacancySummaryService.GetByIds(new List <int> { vacancy.VacancyId }).Single(); var vacancyOwnerRelationship = _providerService.GetVacancyOwnerRelationships(new List <int> { vacancySummary.VacancyOwnerRelationshipId }, false).Single().Value; var employer = _employerService.GetEmployers(new List <int> { vacancyOwnerRelationship.EmployerId }).Single(); var providers = _providerService.GetProviders(new List <int> { vacancy.ContractOwnerId }).Single(); var categories = _referenceDataProvider.GetCategories().ToList(); if (vacancy.VacancyType == VacancyType.Apprenticeship) { _logService.Info($"Publishing apprenticeship summary message for vacancy id {vacancy.VacancyId}"); var apprenticeshipSummary = ApprenticeshipSummaryMapper.GetApprenticeshipSummary(vacancySummary, employer, providers, categories, _logService); var apprenticeshipSummaryUpdate = _mapper.Map <ApprenticeshipSummary, ApprenticeshipSummaryUpdate>(apprenticeshipSummary); apprenticeshipSummaryUpdate.UseAlias = true; _serviceBus.PublishMessage(apprenticeshipSummaryUpdate); _logService.Info($"Published apprenticeship summary message for vacancy id {vacancy.VacancyId}"); } if (vacancy.VacancyType == VacancyType.Traineeship) { _logService.Info($"Publishing traineeship summary message for vacancy id {vacancy.VacancyId}"); var traineeshipSummary = TraineeshipSummaryMapper.GetTraineeshipSummary(vacancySummary, employer, providers, categories, _logService); var traineeshipSummaryUpdate = _mapper.Map <TraineeshipSummary, TraineeshipSummaryUpdate>(traineeshipSummary); traineeshipSummaryUpdate.UseAlias = true; _serviceBus.PublishMessage(traineeshipSummaryUpdate); _logService.Info($"Published traineeship summary message for vacancy id {vacancy.VacancyId}"); } } } catch (Exception ex) { _logService.Warn($"Failed to publish vacancy summary message for vacancy id {vacancy.VacancyId}", ex); } }
public IEnumerable <Category> GetCategories() { return(_referenceDataProvider.GetCategories()); }