예제 #1
0
        public async Task <SelectTrainingProviderViewModel> GetSelectTrainingProviderViewModelAsync(VacancyRouteModel vrm, long?ukprn = null)
        {
            var vacancyTask           = Utility.GetAuthorisedVacancyForEditAsync(_client, _vacancyClient, vrm, RouteNames.TrainingProvider_Select_Get);
            var trainingProvidersTask = _trainingProviderSummaryProvider.FindAllAsync();

            await Task.WhenAll(vacancyTask, trainingProvidersTask);

            var vacancy           = vacancyTask.Result;
            var trainingProviders = trainingProvidersTask.Result;

            var programme = await _vacancyClient.GetApprenticeshipProgrammeAsync(vacancy.ProgrammeId);

            var vm = new SelectTrainingProviderViewModel
            {
                Title             = vacancy.Title,
                TrainingProviders = trainingProviders.Select(t => FormatSuggestion(t.ProviderName, t.Ukprn)),
                PageInfo          = Utility.GetPartOnePageInfo(vacancy),
                Programme         = programme.ToViewModel()
            };

            TrySetSelectedTrainingProvider(vm, trainingProviders, vacancy, ukprn);

            if (vacancy.Status == VacancyStatus.Referred)
            {
                vm.Review = await _reviewSummaryService.GetReviewSummaryViewModelAsync(vacancy.VacancyReference.Value,
                                                                                       ReviewFieldMappingLookups.GetTrainingProviderFieldIndicators());
            }

            return(vm);
        }
예제 #2
0
        public async Task <DurationViewModel> GetDurationViewModelAsync(VacancyRouteModel vrm)
        {
            var vacancy = await Utility.GetAuthorisedVacancyForEditAsync(_client, _vacancyClient, vrm, RouteNames.Duration_Get);

            var training = await _vacancyClient.GetApprenticeshipProgrammeAsync(vacancy.ProgrammeId);

            var vm = new DurationViewModel
            {
                Duration               = vacancy.Wage?.Duration?.ToString(),
                DurationUnit           = vacancy.Wage?.DurationUnit ?? DurationUnit.Month,
                WorkingWeekDescription = vacancy.Wage?.WorkingWeekDescription,
                WeeklyHours            = $"{vacancy.Wage?.WeeklyHours:0.##}",
                PageInfo               = Utility.GetPartOnePageInfo(vacancy),
                TrainingTitle          = training?.Title,
                TrainingDurationMonths = training?.Duration ?? 0
            };

            if (vacancy.Status == VacancyStatus.Referred)
            {
                vm.Review = await _reviewSummaryService.GetReviewSummaryViewModelAsync(vacancy.VacancyReference.Value,
                                                                                       ReviewFieldMappingLookups.GetDurationReviewFieldIndicators());
            }

            return(vm);
        }
예제 #3
0
        /// <summary>
        /// Gets vacancy for display without applications.
        /// </summary>
        /// <param name="vacancy"></param>
        /// <returns></returns>
        public async Task <DisplayVacancyViewModel> GetFullVacancyDisplayViewModelAsync(Vacancy vacancy)
        {
            var programme = await _client.GetApprenticeshipProgrammeAsync(vacancy.ProgrammeId);

            switch (vacancy.Status)
            {
            case VacancyStatus.Approved:
                var approvedViewModel = new ApprovedVacancyViewModel {
                    EducationLevelName = EducationLevelNumberHelper.GetEducationLevelNameOrDefault(programme.EducationLevelNumber, programme.ApprenticeshipLevel)
                };
                await _vacancyDisplayMapper.MapFromVacancyAsync(approvedViewModel, vacancy);

                approvedViewModel.ApprovedDate = vacancy.ApprovedDate.Value.AsGdsDate();
                return(approvedViewModel);

            case VacancyStatus.Live:
                var liveViewModel = new LiveVacancyViewModel {
                    EducationLevelName = EducationLevelNumberHelper.GetEducationLevelNameOrDefault(programme.EducationLevelNumber, programme.ApprenticeshipLevel)
                };
                await _vacancyDisplayMapper.MapFromVacancyAsync(liveViewModel, vacancy);

                return(liveViewModel);

            case VacancyStatus.Closed:
                var closedViewModel = new ClosedVacancyViewModel {
                    EducationLevelName = EducationLevelNumberHelper.GetEducationLevelNameOrDefault(programme.EducationLevelNumber, programme.ApprenticeshipLevel)
                };
                await _vacancyDisplayMapper.MapFromVacancyAsync(closedViewModel, vacancy);

                return(closedViewModel);

            case VacancyStatus.Submitted:
                var submittedViewModel = new SubmittedVacancyViewModel {
                    EducationLevelName = EducationLevelNumberHelper.GetEducationLevelNameOrDefault(programme.EducationLevelNumber, programme.ApprenticeshipLevel)
                };
                await _vacancyDisplayMapper.MapFromVacancyAsync(submittedViewModel, vacancy);

                submittedViewModel.SubmittedDate = vacancy.SubmittedDate.Value.AsGdsDate();
                return(submittedViewModel);

            case VacancyStatus.Review:
                var reviewViewModel = new ReviewVacancyViewModel {
                    EducationLevelName = EducationLevelNumberHelper.GetEducationLevelNameOrDefault(programme.EducationLevelNumber, programme.ApprenticeshipLevel)
                };
                await _vacancyDisplayMapper.MapFromVacancyAsync(reviewViewModel, vacancy);

                return(reviewViewModel);

            default:
                throw new InvalidStateException(string.Format(ErrorMessages.VacancyCannotBeViewed, vacancy.Title));
            }
        }
예제 #4
0
        public async Task MapFromVacancyAsync(DisplayVacancyViewModel vm, Vacancy vacancy)
        {
            var programme = await _vacancyClient.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.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.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.ToString()}"
                                        : 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;
            }
        }