public void IsRecruitVacancy_ShouldReturnTrueForRecruitVacancies()
        {
            long vacancyReference = 1000000000;

            Assert.IsTrue(VacancyVersionHelper.IsRecruitVacancy(vacancyReference));
            Assert.IsFalse(VacancyVersionHelper.IsRaaVacancy(vacancyReference));
        }
Exemple #2
0
        public async Task <ApprenticeshipVacancy> GetApprenticeshipVacancyDetailsAsync(string id)
        {
            ApprenticeshipVacancy vacancy;

            if (!int.TryParse(id, out var parsedId))
            {
                throw _validationExceptionBuilder.Build(
                          ErrorCodes.GetApprenticeship.VacancyReferenceNumberNotInt32,
                          ErrorMessages.GetApprenticeship.VacancyReferenceNumberNotNumeric);
            }
            if (VacancyVersionHelper.IsRaaVacancy(parsedId))
            {
                var response = await _mediator.Send(new GetApprenticeshipVacancyRequest()
                {
                    Reference = parsedId
                })
                               .ConfigureAwait(false);

                vacancy = _mapper.MapToApprenticeshipVacancy(response.ApprenticeshipVacancy);
            }
            else
            {
                var liveVacancy = _recruitClient.GetLiveVacancy(parsedId);
                if (liveVacancy == null)
                {
                    throw new ResourceNotFoundException(Domain.Constants.ErrorMessages.VacancyNotFoundErrorMessage);
                }
                vacancy = await _recruitMapper.MapFromRecruitVacancy(liveVacancy).ConfigureAwait(false);
            }
            return(vacancy);
        }