Beispiel #1
0
        protected void Initialize()
        {
            FixtureInstance = new Fixture().Customize(new AutoMoqCustomization());

            ProvideSettingsMock = FixtureInstance.Freeze <Mock <IProvideSettings> >();

            TrainingDetailServiceMock = FixtureInstance.Freeze <Mock <ITrainingDetailService> >();
            TrainingDetailServiceMock.Setup(t => t.GetStandardDetailsAsync(It.IsAny <int>()))
            .ReturnsAsync(FixtureInstance.Create <Standard>());

            MinimumWageServiceMock = FixtureInstance.Freeze <Mock <IGetMinimumWagesService> >();
            MinimumWageServiceMock.Setup(s => s.GetWageRange(It.IsAny <DateTime>()))
            .Returns <DateTime>(NationalMinimumWageService.GetHourlyRates);

            var wage = FixtureInstance.Build <Wage>()
                       .With(w => w.WageType, RecruitApprenticeshipMapper.FixedWageType)
                       .Create();

            LiveVacancy = FixtureInstance.Build <SFA.DAS.Recruit.Vacancies.Client.Entities.Vacancy>()
                          .Without(v => v.EmployerContactName)
                          .Without(v => v.EmployerContactEmail)
                          .Without(v => v.EmployerContactPhone)
                          .Without(v => v.ProviderContactName)
                          .Without(v => v.ProviderContactEmail)
                          .Without(v => v.ProviderContactPhone)
                          .With(v => v.Wage, wage)
                          .With(v => v.StartDate, new DateTime(2018, 5, 1))
                          .With(v => v.ProgrammeType, "Standard")
                          .With(v => v.ProgrammeId, "123")
                          .With(v => v.IsAnonymous, false)
                          .Create();
        }
        public async Task <ApiTypes.ApprenticeshipVacancy> MapFromRecruitVacancy(recruitEntities.Vacancy liveVacancy)
        {
            var liveVacancyBaseUrl = _provideSettings.GetSetting(ApplicationSettingKeys.LiveApprenticeshipVacancyBaseUrlKey);

            var trainingType =
                (ApiTypes.TrainingType)Enum.Parse(typeof(ApiTypes.TrainingType), liveVacancy.ProgrammeType);

            var trainingCode = GetTrainingCode(trainingType, liveVacancy.ProgrammeId);

            var trainingTitle = await GetTrainingTitle(trainingType, trainingCode);

            var qualifications = GetVacancyQualification(liveVacancy);

            var skills = string.Join(",", liveVacancy.Skills);

            var wageText = GetWageText(liveVacancy.Wage, liveVacancy.StartDate);

            var duration = GetDurationAsText(liveVacancy.Wage);

            var wageUnit = GetWageUnit(liveVacancy.Wage.WageType);

            var apprenticeship = new ApiTypes.ApprenticeshipVacancy
            {
                VacancyReference              = liveVacancy.VacancyReference,
                Title                         = liveVacancy.Title,
                ShortDescription              = liveVacancy.ShortDescription,
                Description                   = liveVacancy.Description,
                WageUnit                      = wageUnit,
                WorkingWeek                   = liveVacancy.Wage.WorkingWeekDescription,
                WageText                      = wageText,
                WageAdditionalInformation     = liveVacancy.Wage.WageAdditionalInformation,
                HoursPerWeek                  = liveVacancy.Wage.WeeklyHours,
                ExpectedDuration              = duration,
                ExpectedStartDate             = liveVacancy.StartDate,
                PostedDate                    = liveVacancy.LiveDate,
                ApplicationClosingDate        = liveVacancy.ClosingDate,
                NumberOfPositions             = liveVacancy.NumberOfPositions,
                EmployerName                  = liveVacancy.EmployerName,
                EmployerDescription           = liveVacancy.EmployerDescription,
                EmployerWebsite               = liveVacancy.IsAnonymous ? null : liveVacancy.EmployerWebsiteUrl,
                ContactName                   = liveVacancy.EmployerContactName ?? liveVacancy.ProviderContactName,
                ContactEmail                  = liveVacancy.EmployerContactEmail ?? liveVacancy.ProviderContactEmail,
                ContactNumber                 = liveVacancy.EmployerContactPhone ?? liveVacancy.ProviderContactPhone,
                TrainingToBeProvided          = liveVacancy.TrainingDescription,
                QualificationsRequired        = qualifications,
                SkillsRequired                = skills,
                PersonalQualities             = null,
                ApplicationInstructions       = liveVacancy.ApplicationInstructions,
                ApplicationUrl                = liveVacancy.ApplicationUrl,
                FutureProspects               = liveVacancy.OutcomeDescription,
                ThingsToConsider              = liveVacancy.ThingsToConsider,
                IsNationwide                  = false,
                SupplementaryQuestion1        = null,
                SupplementaryQuestion2        = null,
                VacancyUrl                    = $"{liveVacancyBaseUrl}/{liveVacancy.VacancyReference}",
                Location                      = MapFromRecruitAddress(liveVacancy.EmployerLocation, liveVacancy.IsAnonymous),
                TrainingProviderName          = liveVacancy.TrainingProvider.Name,
                TrainingProviderUkprn         = liveVacancy.TrainingProvider.Ukprn.ToString(),
                TrainingProviderSite          = null,
                IsEmployerDisabilityConfident = false,
                ApprenticeshipLevel           = liveVacancy.ProgrammeLevel,
                TrainingType                  = trainingType,
                TrainingCode                  = trainingCode,
                TrainingTitle                 = trainingTitle
            };

            return(apprenticeship);
        }
        private string GetVacancyQualification(recruitEntities.Vacancy liveVacancy)
        {
            var formattedDescriptions = liveVacancy.Qualifications.Select(q => $"{q.QualificationType} {q.Subject} (Grade {q.Grade}) {q.Weighting}");

            return(string.Join(",", formattedDescriptions));
        }