public async Task <SearchResultPreviewViewModel> GetSearchResultPreviewViewModelAsync(VacancyRouteModel vrm)
        {
            var vacancy = await Utility.GetAuthorisedVacancyForEditAsync(_client, _vacancyClient, vrm, RouteNames.SearchResultPreview_Get);

            var wagePeriod = _wageProvider.GetWagePeriod(vacancy.StartDate.Value);

            var vm = new SearchResultPreviewViewModel
            {
                EmployerName      = vacancy.EmployerName,
                NumberOfPositions = vacancy.NumberOfPositions?.ToString(),
                ShortDescription  = vacancy.ShortDescription,
                ClosingDate       = vacancy.ClosingDate?.AsGdsDate(),
                StartDate         = vacancy.StartDate?.AsGdsDate(),
                LevelName         = await GetLevelName(vacancy.ProgrammeId),
                Title             = vacancy.Title,
                Wage                  = vacancy.Wage?.ToText(vacancy.StartDate),
                HasYearlyWage         = (vacancy.Wage != null && vacancy.Wage.WageType != WageType.Unspecified),
                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);
            }

            return(vm);
        }
Exemplo n.º 2
0
 private void SetEmployerAddressElements(ReviewViewModel vm, Vacancy vacancy)
 {
     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));
 }
        public static string GetEmployerLocationMapUrl(Vacancy vacancy, IGeocodeImageService mapService, int width, int height)
        {
            if (vacancy.EmployerLocation.HasGeocode)
            {
                return(mapService.GetMapImageUrl(
                           vacancy.EmployerLocation.Latitude.ToString(),
                           vacancy.EmployerLocation.Longitude.ToString(),
                           width,
                           height,
                           vacancy.GeocodeUsingOutcode == false));
            }

            return(vacancy.GeocodeUsingOutcode
                ? mapService.GetMapImageUrl(vacancy.EmployerLocation.PostcodeAsOutcode(), width, height, false)
                : mapService.GetMapImageUrl(vacancy.EmployerLocation.Postcode, width, height, true));
        }
Exemplo n.º 4
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;
            }
        }