Exemple #1
0
        public async Task MapFromVacancyAsync(DisplayVacancyViewModel vm, Vacancy vacancy)
        {
            var programme = await _client.GetApprenticeshipProgrammeAsync(vacancy.ProgrammeId);

            var allQualifications = await _vacancyClient.GetCandidateQualificationsAsync();

            vm.ApplicationMethod       = vacancy.ApplicationMethod;
            vm.ApplicationInstructions = vacancy.ApplicationInstructions;
            vm.ApplicationUrl          = vacancy.ApplicationUrl;
            vm.CanDelete                = vacancy.CanDelete;
            vm.CanSubmit                = vacancy.CanSubmit;
            vm.ClosingDate              = vacancy.ClosingDate?.AsGdsDate();
            vm.EmployerContactName      = vacancy.EmployerContact?.Name;
            vm.EmployerContactEmail     = vacancy.EmployerContact?.Email;
            vm.EmployerContactTelephone = vacancy.EmployerContact?.Phone;
            vm.EmployerDescription      = await GetEmployerDescriptionAsync(vacancy);

            vm.EmployerName             = vacancy.EmployerName;
            vm.EmployerWebsiteUrl       = vacancy.EmployerWebsiteUrl;
            vm.EmployerAddressElements  = Enumerable.Empty <string>();
            vm.FindAnApprenticeshipUrl  = _externalLinksConfiguration.FindAnApprenticeshipUrl;
            vm.NumberOfPositions        = vacancy.NumberOfPositions?.ToString();
            vm.NumberOfPositionsCaption = vacancy.NumberOfPositions.HasValue
                ? $"{"position".ToQuantity(vacancy.NumberOfPositions.Value)} available"
                : null;
            vm.OutcomeDescription = vacancy.OutcomeDescription;
            vm.PossibleStartDate  = vacancy.StartDate?.AsGdsDate();
            vm.ProviderName       = vacancy.TrainingProvider?.Name;
            vm.Qualifications     = vacancy.Qualifications.SortQualifications(allQualifications).AsText();
            vm.ShortDescription   = vacancy.ShortDescription;
            vm.Skills             = vacancy.Skills ?? Enumerable.Empty <string>();
            vm.ThingsToConsider   = vacancy.ThingsToConsider;
            vm.Title = vacancy.Title;
            vm.TrainingDescription    = vacancy.TrainingDescription;
            vm.VacancyDescription     = vacancy.Description;
            vm.VacancyReferenceNumber = vacancy.VacancyReference.HasValue
                                        ? $"VAC{vacancy.VacancyReference.ToString()}"
                                        : string.Empty;
            vm.IsDisabilityConfident = vacancy.IsDisabilityConfident;
            if (vacancy.EmployerLocation != null)
            {
                vm.MapUrl = vacancy.EmployerLocation.HasGeocode
                    ? _mapService.GetMapImageUrl(vacancy.EmployerLocation.Latitude.ToString(),
                                                 vacancy.EmployerLocation.Longitude.ToString(), MapImageWidth, MapImageHeight)
                    : _mapService.GetMapImageUrl(vacancy.EmployerLocation.Postcode, MapImageWidth, MapImageHeight);
                vm.EmployerAddressElements = new[]
                {
                    vacancy.EmployerLocation.AddressLine1,
                    vacancy.EmployerLocation.AddressLine2,
                    vacancy.EmployerLocation.AddressLine3,
                    vacancy.EmployerLocation.AddressLine4,
                    vacancy.EmployerLocation.Postcode
                }
                .Where(x => !string.IsNullOrEmpty(x));
            }

            if (vacancy.ProgrammeId != null)
            {
                vm.TrainingTitle = programme?.Title;
                vm.TrainingType  = programme?.ApprenticeshipType.GetDisplayName();
                vm.TrainingLevel = programme?.Level.GetDisplayName();
            }

            if (vacancy.Wage != null)
            {
                vm.ExpectedDuration = (vacancy.Wage.DurationUnit.HasValue && vacancy.Wage.Duration.HasValue)
                    ? vacancy.Wage.DurationUnit.Value.GetDisplayName().ToQuantity(vacancy.Wage.Duration.Value)
                    : null;
                vm.HoursPerWeek           = $"{vacancy.Wage.WeeklyHours:0.##}";
                vm.WageInfo               = vacancy.Wage.WageAdditionalInformation;
                vm.WageText               = vacancy.StartDate.HasValue ? vacancy.Wage.ToText(vacancy.StartDate) : null;
                vm.WorkingWeekDescription = vacancy.Wage.WorkingWeekDescription;
            }
        }
        public async Task MapFromVacancyAsync(DisplayVacancyViewModel vm, Vacancy vacancy)
        {
            var programme = await _vacancyClient.GetApprenticeshipProgrammeAsync(vacancy.ProgrammeId);

            var employer = await _client.GetProviderEmployerVacancyDataAsync(vacancy.TrainingProvider.Ukprn.Value, vacancy.EmployerAccountId);

            var allQualifications = await _vacancyClient.GetCandidateQualificationsAsync();

            vm.Status                  = vacancy.Status;
            vm.AccountName             = employer.Name;
            vm.ApplicationMethod       = vacancy.ApplicationMethod;
            vm.ApplicationInstructions = vacancy.ApplicationInstructions;
            vm.ApplicationUrl          = vacancy.ApplicationUrl;
            vm.CanDelete               = vacancy.CanDelete;
            vm.CanSubmit               = vacancy.CanSubmit;
            vm.IsSentForReview         = vacancy.Status == VacancyStatus.Review;
            vm.ClosingDate             = (vacancy.ClosedDate ?? vacancy.ClosingDate)?.AsGdsDate();
            vm.EducationLevelName      = EducationLevelNumberHelper.GetEducationLevelNameOrDefault(programme.EducationLevelNumber, programme.ApprenticeshipLevel);
            vm.EmployerDescription     = vacancy.EmployerDescription;
            vm.EmployerName            = await _vacancyClient.GetEmployerNameAsync(vacancy);

            vm.EmployerWebsiteUrl            = vacancy.EmployerWebsiteUrl;
            vm.EmployerAddressElements       = Enumerable.Empty <string>();
            vm.EmployerRejectedReason        = vacancy.EmployerRejectedReason;
            vm.EmployerReviewFieldIndicators = vacancy.EmployerReviewFieldIndicators;
            vm.FindAnApprenticeshipUrl       = _externalLinksConfiguration.FindAnApprenticeshipUrl;
            vm.IsAnonymous              = vacancy.IsAnonymous;
            vm.NumberOfPositions        = vacancy.NumberOfPositions?.ToString();
            vm.NumberOfPositionsCaption = vacancy.NumberOfPositions.HasValue
                ? $"{"position".ToQuantity(vacancy.NumberOfPositions.Value)} available"
                : null;
            vm.OutcomeDescription       = vacancy.OutcomeDescription;
            vm.PossibleStartDate        = vacancy.StartDate?.AsGdsDate();
            vm.ProviderContactName      = vacancy.ProviderContact?.Name;
            vm.ProviderContactEmail     = vacancy.ProviderContact?.Email;
            vm.ProviderContactTelephone = vacancy.ProviderContact?.Phone;
            vm.ProviderName             = vacancy.TrainingProvider?.Name;
            vm.Qualifications           = vacancy.Qualifications.SortQualifications(allQualifications).AsText();
            vm.ShortDescription         = vacancy.ShortDescription;
            vm.Skills                 = vacancy.Skills ?? Enumerable.Empty <string>();
            vm.ThingsToConsider       = vacancy.ThingsToConsider;
            vm.Title                  = vacancy.Title;
            vm.TrainingDescription    = vacancy.TrainingDescription;
            vm.VacancyDescription     = vacancy.Description;
            vm.VacancyReferenceNumber = vacancy.VacancyReference.HasValue
                                        ? $"VAC{vacancy.VacancyReference}"
                                        : string.Empty;
            vm.IsDisabilityConfident = vacancy.IsDisabilityConfident;

            if (vacancy.EmployerLocation != null)
            {
                vm.MapUrl = MapImageHelper.GetEmployerLocationMapUrl(vacancy, _mapService, MapImageWidth, MapImageHeight);

                vm.EmployerAddressElements = vacancy.EmployerAddressForDisplay();
            }

            if (vacancy.ProgrammeId != null)
            {
                vm.TrainingTitle = programme.Title;
                vm.TrainingType  = programme.ApprenticeshipType.GetDisplayName();
                vm.TrainingLevel = programme.ApprenticeshipLevel.GetDisplayName();
            }

            if (vacancy.Wage != null)
            {
                vm.ExpectedDuration = (vacancy.Wage.DurationUnit.HasValue && vacancy.Wage.Duration.HasValue)
                    ? vacancy.Wage.DurationUnit.Value.GetDisplayName().ToQuantity(vacancy.Wage.Duration.Value)
                    : null;
                vm.HoursPerWeek           = $"{vacancy.Wage.WeeklyHours:0.##}";
                vm.WageInfo               = vacancy.Wage.WageAdditionalInformation;
                vm.WageText               = vacancy.StartDate.HasValue ? vacancy.Wage.ToText(vacancy.StartDate) : null;
                vm.WorkingWeekDescription = vacancy.Wage.WorkingWeekDescription;
            }
        }