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 Vacancy UpsertVacancy(Vacancy vacancy, Func <Vacancy, Vacancy> operation) { Condition.Requires(vacancy); _authoriseCurrentUserStrategy.AuthoriseCurrentUser(vacancy); if (_currentUserService.IsInRole(Roles.Faa)) { var username = _currentUserService.CurrentUserName; var lastEditedBy = _providerUserReadRepository.GetByUsername(username); if (lastEditedBy != null) { vacancy.LastEditedById = lastEditedBy.ProviderUserId; } } vacancy = operation(vacancy); _publishVacancySummaryUpdateStrategy.PublishVacancySummaryUpdate(vacancy); return(_vacancyReadRepository.Get(vacancy.VacancyId)); }
public void ProcessVacancyClosure(VacancyEligibleForClosure vacancyEligibleForClosure) { var vacancy = _vacancyReadRepository.Get(vacancyEligibleForClosure.VacancyId); switch (vacancy.Status) { case VacancyStatus.Live: vacancy.Status = VacancyStatus.Closed; _vacancyWriteRepository.Update(vacancy); break; default: return; } }
public Vacancy GetVacancyById(int vacancyId) { return(_authoriseCurrentUserStrategy.AuthoriseCurrentUser(_vacancyReadRepository.Get(vacancyId))); }