public async Task <TrainingViewModel> GetTrainingViewModelAsync(VacancyRouteModel vrm, VacancyUser user)
        {
            var vacancyTask             = _utility.GetAuthorisedVacancyForEditAsync(vrm, RouteNames.Training_Get);
            var programmesTask          = _vacancyClient.GetActiveApprenticeshipProgrammesAsync();
            var isUsersFirstVacancyTask = IsUsersFirstVacancy(user.UserId);
            var getEmployerDataTask     = _employerVacancyClient.GetEditVacancyInfoAsync(vrm.EmployerAccountId);

            await Task.WhenAll(vacancyTask, programmesTask, isUsersFirstVacancyTask, getEmployerDataTask);

            var vacancy    = vacancyTask.Result;
            var programmes = programmesTask.Result;

            var vm = new TrainingViewModel
            {
                VacancyId                 = vacancy.Id,
                SelectedProgrammeId       = vacancy.ProgrammeId,
                Programmes                = programmes.ToViewModel(),
                IsUsersFirstVacancy       = isUsersFirstVacancyTask.Result && vacancy.TrainingProvider == null,
                PageInfo                  = _utility.GetPartOnePageInfo(vacancy),
                HasMoreThanOneLegalEntity = getEmployerDataTask.Result.LegalEntities.Count() > 1
            };

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

            return(vm);
        }
Exemple #2
0
        public async Task <TitleViewModel> GetTitleViewModelForExistingVacancyAsync(VacancyRouteModel vrm)
        {
            var vacancy = await Utility.GetAuthorisedVacancyForEditAsync(_providerVacancyClient, _recruitVacancyClient, vrm, RouteNames.Title_Get);

            var ukprn     = vacancy.TrainingProvider.Ukprn.GetValueOrDefault();
            var dashboard = await _providerVacancyClient.GetDashboardAsync(ukprn);

            var vm = new TitleViewModel
            {
                VacancyId         = vacancy.Id,
                Title             = vacancy.Title,
                PageInfo          = Utility.GetPartOnePageInfo(vacancy),
                Ukprn             = ukprn,
                EmployerAccountId = vacancy.EmployerAccountId,
                HasAnyVacancies   = dashboard.Vacancies.Any()
            };

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

            return(vm);
        }
Exemple #3
0
        public async Task <DatesViewModel> GetDatesViewModelAsync(VacancyRouteModel vrm)
        {
            var vacancy = await Utility.GetAuthorisedVacancyForEditAsync(_client, _vacancyClient, vrm, RouteNames.Dates_Get);

            var vm = new DatesViewModel
            {
                VacancyId             = vacancy.Id,
                IsDisabilityConfident = vacancy.IsDisabilityConfident,
                PageInfo    = Utility.GetPartOnePageInfo(vacancy),
                CurrentYear = _timeProvider.Now.Year
            };

            if (vacancy.ClosingDate.HasValue)
            {
                vm.ClosingDay   = $"{vacancy.ClosingDate.Value.Day:00}";
                vm.ClosingMonth = $"{vacancy.ClosingDate.Value.Month:00}";
                vm.ClosingYear  = $"{vacancy.ClosingDate.Value.Year}";
            }

            if (vacancy.StartDate.HasValue)
            {
                vm.StartDay   = $"{vacancy.StartDate.Value.Day:00}";
                vm.StartMonth = $"{vacancy.StartDate.Value.Month:00}";
                vm.StartYear  = $"{vacancy.StartDate.Value.Year}";
            }

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

            return(vm);
        }
        public async Task <TrainingViewModel> GetTrainingViewModelAsync(VacancyRouteModel vrm, VacancyUser user)
        {
            var vacancyTask = Utility.GetAuthorisedVacancyForEditAsync(
                _client, _vacancyClient, vrm, RouteNames.Training_Get);
            var programmesTask = _vacancyClient.GetActiveApprenticeshipProgrammesAsync();

            await Task.WhenAll(vacancyTask, programmesTask);

            var vacancy    = vacancyTask.Result;
            var programmes = programmesTask.Result;

            var vm = new TrainingViewModel
            {
                VacancyId           = vacancy.Id,
                SelectedProgrammeId = vacancy.ProgrammeId,
                Programmes          = programmes.ToViewModel(),
                PageInfo            = Utility.GetPartOnePageInfo(vacancy),
            };

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

            return(vm);
        }
Exemple #5
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);
        }
Exemple #6
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);
        }
Exemple #7
0
        public async Task <WageViewModel> GetWageViewModelAsync(VacancyRouteModel vrm)
        {
            var vacancy = await Utility.GetAuthorisedVacancyForEditAsync(_client, _vacancyClient, vrm, RouteNames.Wage_Get);

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

            var vm = new WageViewModel
            {
                WageType = vacancy.Wage?.WageType,
                FixedWageYearlyAmount               = vacancy.Wage?.FixedWageYearlyAmount?.AsMoney(),
                WageAdditionalInformation           = vacancy.Wage?.WageAdditionalInformation,
                MinimumWageStartFrom                = wagePeriod.ValidFrom.ToMonthNameYearString(),
                NationalMinimumWageLowerBoundHourly = wagePeriod.NationalMinimumWageLowerBound.ToString("C"),
                NationalMinimumWageUpperBoundHourly = wagePeriod.NationalMinimumWageUpperBound.ToString("C"),
                NationalMinimumWageYearly           = GetMinimumWageYearlyText(SFA.DAS.VacancyServices.Wage.WageType.NationalMinimum, vacancy.Wage?.WeeklyHours, vacancy.StartDate.Value),
                ApprenticeshipMinimumWageHourly     = wagePeriod.ApprenticeshipMinimumWage.ToString("C"),
                ApprenticeshipMinimumWageYearly     = GetMinimumWageYearlyText(SFA.DAS.VacancyServices.Wage.WageType.ApprenticeshipMinimum, vacancy.Wage?.WeeklyHours, vacancy.StartDate.Value),
                WeeklyHours = vacancy.Wage.WeeklyHours.Value,
                PageInfo    = Utility.GetPartOnePageInfo(vacancy)
            };

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

            return(vm);
        }
        public async Task <VacancyPreviewViewModel> GetVacancyPreviewViewModelAsync(VacancyRouteModel vrm)
        {
            var vacancyTask    = Utility.GetAuthorisedVacancyForEditAsync(_client, _vacancyClient, vrm, RouteNames.Vacancy_Preview_Get);
            var programmesTask = _vacancyClient.GetActiveApprenticeshipProgrammesAsync();

            await Task.WhenAll(vacancyTask, programmesTask);

            var vacancy   = vacancyTask.Result;
            var programme = programmesTask.Result.SingleOrDefault(p => p.Id == vacancy.ProgrammeId);
            var hasProviderReviewPermission = await _providerRelationshipsService.HasProviderGotEmployersPermissionAsync(vrm.Ukprn, vacancy.EmployerAccountId, vacancy.AccountLegalEntityPublicHashedId, OperationType.RecruitmentRequiresReview);

            var vm = new VacancyPreviewViewModel();
            await _vacancyDisplayMapper.MapFromVacancyAsync(vm, vacancy);

            vm.HasProgramme           = vacancy.ProgrammeId != null;
            vm.HasWage                = vacancy.Wage != null;
            vm.CanShowReference       = vacancy.Status != VacancyStatus.Draft;
            vm.CanShowDraftHeader     = vacancy.Status == VacancyStatus.Draft;
            vm.SoftValidationErrors   = GetSoftValidationErrors(vacancy);
            vm.RequiresEmployerReview = hasProviderReviewPermission;

            if (programme != null)
            {
                vm.ApprenticeshipLevel = programme.ApprenticeshipLevel;
            }

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

            return(vm);
        }
Exemple #9
0
        public async Task <SkillsViewModel> GetSkillsViewModelAsync(VacancyRouteModel vrm, string[] draftSkills = null)
        {
            var vacancy = await Utility.GetAuthorisedVacancyForEditAsync(_client, _vacancyClient, vrm, RouteNames.Skills_Get);

            var vm = new SkillsViewModel
            {
                Title = vacancy.Title
            };

            if (draftSkills == null)
            {
                _skillsHelper.SetViewModelSkillsFromVacancy(vm, vacancy);
            }
            else
            {
                _skillsHelper.SetViewModelSkillsFromDraftSkills(vm, draftSkills);
            }

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

            return(vm);
        }
Exemple #10
0
        public async Task <VacancyPreviewViewModel> GetVacancyPreviewViewModelAsync(VacancyRouteModel vrm)
        {
            var vacancyTask    = Utility.GetAuthorisedVacancyForEditAsync(_client, _vacancyClient, vrm, RouteNames.Vacancy_Preview_Get);
            var programmesTask = _vacancyClient.GetActiveApprenticeshipProgrammesAsync();

            await Task.WhenAll(vacancyTask, programmesTask);

            var vacancy   = vacancyTask.Result;
            var programme = programmesTask.Result.SingleOrDefault(p => p.Id == vacancy.ProgrammeId);
            var vm        = new VacancyPreviewViewModel();
            await _vacancyDisplayMapper.MapFromVacancyAsync(vm, vacancy);

            vm.HasProgramme         = vacancy.ProgrammeId != null;
            vm.HasWage              = vacancy.Wage != null;
            vm.CanShowReference     = vacancy.Status != VacancyStatus.Draft;
            vm.CanShowDraftHeader   = vacancy.Status == VacancyStatus.Draft;
            vm.SoftValidationErrors = GetSoftValidationErrors(vacancy);

            if (programme != null)
            {
                vm.Level = programme.Level;
            }

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

            return(vm);
        }
        public async Task <QualificationsViewModel> GetQualificationsViewModelAsync(VacancyRouteModel vrm)
        {
            var vacancy = await _utility.GetAuthorisedVacancyForEditAsync(vrm, RouteNames.Qualifications_Get);

            var qualifications = vacancy.Qualifications ?? new List <Qualification>();

            var vm = new QualificationsViewModel
            {
                Title          = vacancy.Title,
                Qualifications = qualifications.Select(q => new QualificationEditModel
                {
                    Subject           = q.Subject,
                    QualificationType = q.QualificationType,
                    Weighting         = q.Weighting,
                    Grade             = q.Grade
                }).ToList()
            };

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

            return(vm);
        }
        public async Task <LocationViewModel> GetLocationViewModelAsync(
            VacancyRouteModel vrm, VacancyEmployerInfoModel employerInfoModel, VacancyUser user)
        {
            var vacancy = await Utility.GetAuthorisedVacancyForEditAsync(_employerVacancyClient, _recruitVacancyClient,
                                                                         vrm, RouteNames.Location_Get);

            var accountLegalEntityPublicHashedId = employerInfoModel?.AccountLegalEntityPublicHashedId != null
                ? employerInfoModel.AccountLegalEntityPublicHashedId
                : vacancy.AccountLegalEntityPublicHashedId;

            var vm = new LocationViewModel();

            vm.PageInfo = Utility.GetPartOnePageInfo(vacancy);

            vm.IsAnonymousVacancy = (employerInfoModel?.EmployerIdentityOption == null)
                ? vacancy.IsAnonymous
                : employerInfoModel.EmployerIdentityOption == EmployerIdentityOption.Anonymous;

            var employerProfile =
                await _recruitVacancyClient.GetEmployerProfileAsync(vacancy.EmployerAccountId, accountLegalEntityPublicHashedId);

            var allLocations = await GetAllAvailableLocationsAsync(employerProfile);

            vm.AvailableLocations = allLocations.Select(a => a.ToAddressString()).ToList();

            var hasLegalEntityChanged = employerInfoModel?.HasLegalEntityChanged ?? false;

            if (vacancy.EmployerLocation != null && hasLegalEntityChanged == false)
            {
                var matchingAddress = GetMatchingAddress(vacancy.EmployerLocation.ToAddressString(), allLocations);
                if (matchingAddress == null)
                {
                    vm.SelectedLocation = LocationViewModel.UseOtherLocationConst;
                    vm.SetLocation(vacancy.EmployerLocation);
                }
                else
                {
                    vm.SelectedLocation = matchingAddress.ToAddressString();
                }
            }

            if (vacancy.Status == VacancyStatus.Referred)
            {
                vm.Review = await _reviewSummaryService.GetReviewSummaryViewModelAsync(vacancy.VacancyReference.Value,
                                                                                       ReviewFieldMappingLookups.GetLocationFieldIndicators());
            }
            return(vm);
        }
        public async Task <SelectTrainingProviderViewModel> GetSelectTrainingProviderViewModel(VacancyRouteModel vrm)
        {
            var vacancy = await Utility.GetAuthorisedVacancyForEditAsync(_client, _vacancyClient, vrm, RouteNames.TrainingProvider_Select_Get);

            var vm = new SelectTrainingProviderViewModel
            {
                Title = vacancy.Title,
                Ukprn = vacancy.TrainingProvider?.Ukprn?.ToString()
            };

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

            return(vm);
        }
Exemple #14
0
        public async Task <ConsiderationsViewModel> GetConsiderationsViewModelAsync(VacancyRouteModel vrm)
        {
            var vacancy = await Utility.GetAuthorisedVacancyForEditAsync(_client, _vacancyClient, vrm, RouteNames.Considerations_Get);

            var vm = new ConsiderationsViewModel
            {
                Title            = vacancy.Title,
                ThingsToConsider = vacancy.ThingsToConsider,
            };

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

            return(vm);
        }
        public async Task <ShortDescriptionViewModel> GetShortDescriptionViewModelAsync(VacancyRouteModel vrm)
        {
            var vacancy = await Utility.GetAuthorisedVacancyForEditAsync(_client, _vacancyClient, vrm, RouteNames.ShortDescription_Get);

            var vm = new ShortDescriptionViewModel
            {
                VacancyId        = vacancy.Id,
                ShortDescription = vacancy.ShortDescription,
                Title            = vacancy.Title
            };

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

            return(vm);
        }
        public async Task <EmployerViewModel> GetEmployerViewModelAsync(VacancyRouteModel vrm)
        {
            var getEmployerDataTask = _client.GetEditVacancyInfoAsync(vrm.EmployerAccountId);
            var getVacancyTask      = Utility.GetAuthorisedVacancyForEditAsync(_client, _vacancyClient, vrm, RouteNames.Employer_Get);

            await Task.WhenAll(getEmployerDataTask, getVacancyTask);

            var employerData = getEmployerDataTask.Result;
            var vacancy      = getVacancyTask.Result;

            var vm = new EmployerViewModel
            {
                Organisations          = BuildLegalEntityViewModels(employerData, vrm.EmployerAccountId),
                SelectedOrganisationId = vacancy.LegalEntityId,
                PageInfo = Utility.GetPartOnePageInfo(vacancy)
            };

            if (vacancy.EmployerLocation != null)
            {
                vm.AddressLine1 = vacancy.EmployerLocation.AddressLine1;
                vm.AddressLine2 = vacancy.EmployerLocation.AddressLine2;
                vm.AddressLine3 = vacancy.EmployerLocation.AddressLine3;
                vm.AddressLine4 = vacancy.EmployerLocation.AddressLine4;
                vm.Postcode     = vacancy.EmployerLocation.Postcode;
            }
            else if (employerData.LegalEntities.Count() == 1 && vacancy.EmployerLocation == null)
            {
                var defaultLegalEntity = employerData.LegalEntities.First();
                vm.AddressLine1 = defaultLegalEntity.Address.AddressLine1;
                vm.AddressLine2 = defaultLegalEntity.Address.AddressLine2;
                vm.AddressLine3 = defaultLegalEntity.Address.AddressLine3;
                vm.AddressLine4 = defaultLegalEntity.Address.AddressLine4;
                vm.Postcode     = defaultLegalEntity.Address.Postcode;
            }

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

            return(vm);
        }
Exemple #17
0
        public async Task <NumberOfPositionsViewModel> GetNumberOfPositionsViewModelAsync(VacancyRouteModel vrm)
        {
            var vacancy = await Utility.GetAuthorisedVacancyForEditAsync(_client, _vacancyClient, vrm, RouteNames.NumberOfPositions_Get);

            var vm = new NumberOfPositionsViewModel
            {
                VacancyId         = vacancy.Id,
                NumberOfPositions = vacancy.NumberOfPositions?.ToString(),
                PageInfo          = Utility.GetPartOnePageInfo(vacancy)
            };

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

            return(vm);
        }
        public async Task <AboutEmployerViewModel> GetAboutEmployerViewModelAsync(VacancyRouteModel vrm)
        {
            var vacancy = await Utility.GetAuthorisedVacancyForEditAsync(_client, _vacancyClient, vrm, RouteNames.AboutEmployer_Get);

            var vm = new AboutEmployerViewModel
            {
                Title = vacancy.Title,
                EmployerDescription = await GetEmployerDescriptionAsync(vacancy),
                EmployerWebsiteUrl  = vacancy.EmployerWebsiteUrl
            };

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

            return(vm);
        }
        public async Task <TrainingViewModel> GetTrainingViewModelAsync(VacancyRouteModel vrm)
        {
            var vacancyTask    = Utility.GetAuthorisedVacancyForEditAsync(_client, _vacancyClient, vrm, RouteNames.Training_Get);
            var programmesTask = _client.GetActiveApprenticeshipProgrammesAsync();

            await Task.WhenAll(vacancyTask, programmesTask);

            var vacancy    = vacancyTask.Result;
            var programmes = programmesTask.Result;

            var vm = new TrainingViewModel
            {
                VacancyId             = vacancy.Id,
                SelectedProgrammeId   = vacancy.ProgrammeId,
                Programmes            = programmes.ToViewModel(),
                IsDisabilityConfident = vacancy.IsDisabilityConfident,
                PageInfo    = Utility.GetPartOnePageInfo(vacancy),
                CurrentYear = _timeProvider.Now.Year
            };

            if (vacancy.ClosingDate.HasValue)
            {
                vm.ClosingDay   = $"{vacancy.ClosingDate.Value.Day:00}";
                vm.ClosingMonth = $"{vacancy.ClosingDate.Value.Month:00}";
                vm.ClosingYear  = $"{vacancy.ClosingDate.Value.Year}";
            }

            if (vacancy.StartDate.HasValue)
            {
                vm.StartDay   = $"{vacancy.StartDate.Value.Day:00}";
                vm.StartMonth = $"{vacancy.StartDate.Value.Month:00}";
                vm.StartYear  = $"{vacancy.StartDate.Value.Year}";
            }

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

            return(vm);
        }
        public async Task <EmployerContactDetailsViewModel> GetEmployerContactDetailsViewModelAsync(VacancyRouteModel vrm)
        {
            var vacancy = await Utility.GetAuthorisedVacancyForEditAsync(_client, _vacancyClient, vrm, RouteNames.EmployerContactDetails_Get);

            var vm = new EmployerContactDetailsViewModel
            {
                Title = vacancy.Title,
                EmployerContactName  = vacancy.EmployerContact?.Name,
                EmployerContactEmail = vacancy.EmployerContact?.Email,
                EmployerContactPhone = vacancy.EmployerContact?.Phone
            };

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

            return(vm);
        }
Exemple #21
0
        public async Task <VacancyDescriptionViewModel> GetVacancyDescriptionViewModelAsync(VacancyRouteModel vrm)
        {
            var vacancy = await Utility.GetAuthorisedVacancyForEditAsync(_client, _vacancyClient, vrm, RouteNames.VacancyDescription_Index_Get);

            var vm = new VacancyDescriptionViewModel
            {
                Title = vacancy.Title,
                VacancyDescription  = vacancy.Description,
                TrainingDescription = vacancy.TrainingDescription,
                OutcomeDescription  = vacancy.OutcomeDescription
            };

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

            return(vm);
        }
        public async Task <VacancyPreviewViewModel> GetVacancyPreviewViewModelAsync(VacancyRouteModel vrm)
        {
            var vacancy = await Utility.GetAuthorisedVacancyForEditAsync(_client, _vacancyClient, vrm, RouteNames.Vacancy_Preview_Get);

            var vm = new VacancyPreviewViewModel();
            await _vacancyDisplayMapper.MapFromVacancyAsync(vm, vacancy);

            vm.HasProgramme       = vacancy.ProgrammeId != null;
            vm.HasWage            = vacancy.Wage != null;
            vm.CanShowReference   = vacancy.Status != VacancyStatus.Draft;
            vm.CanShowDraftHeader = vacancy.Status == VacancyStatus.Draft;

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

            return(vm);
        }
        public async Task <EmployerNameViewModel> GetEmployerNameViewModelAsync(VacancyRouteModel vrm, VacancyEmployerInfoModel employerInfoModel)
        {
            var vacancy = await _utility.GetAuthorisedVacancyForEditAsync(vrm, RouteNames.Employer_Get);

            var accountLegalEntityPublicHashedId = employerInfoModel?.AccountLegalEntityPublicHashedId ?? vacancy.AccountLegalEntityPublicHashedId;

            if (string.IsNullOrEmpty(accountLegalEntityPublicHashedId))
            {
                return(null);
            }

            var getEmployerDataTask    = _employerVacancyClient.GetEditVacancyInfoAsync(vrm.EmployerAccountId);
            var getEmployerProfileTask = _recruitVacancyClient.GetEmployerProfileAsync(vrm.EmployerAccountId, accountLegalEntityPublicHashedId);
            await Task.WhenAll(getEmployerDataTask, getEmployerProfileTask);

            var editVacancyInfo = getEmployerDataTask.Result;
            var employerProfile = getEmployerProfileTask.Result;

            var legalEntity = editVacancyInfo.LegalEntities.Single(l => l.AccountLegalEntityPublicHashedId == accountLegalEntityPublicHashedId);

            var vm = new EmployerNameViewModel
            {
                HasOnlyOneOrganisation = editVacancyInfo.LegalEntities.Count() == 1,
                LegalEntityName        = legalEntity.Name,
                ExistingTradingName    = employerProfile.TradingName,
                PageInfo = _utility.GetPartOnePageInfo(vacancy),
                SelectedEmployerIdentityOption = employerInfoModel?.EmployerIdentityOption ?? vacancy?.EmployerNameOption?.ConvertToModelOption(),
                NewTradingName    = employerInfoModel?.NewTradingName,
                AnonymousName     = employerInfoModel?.AnonymousName,
                AnonymousReason   = employerInfoModel?.AnonymousReason ?? vacancy?.AnonymousReason,
                TaskListCompleted = _utility.TaskListCompleted(vacancy)
            };

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

            return(vm);
        }
Exemple #24
0
        public async Task <ApplicationProcessViewModel> GetApplicationProcessViewModelAsync(VacancyRouteModel vrm)
        {
            var vacancy = await Utility.GetAuthorisedVacancyForEditAsync(_client, _vacancyClient, vrm, RouteNames.ApplicationProcess_Get);

            var vm = new ApplicationProcessViewModel
            {
                Title = vacancy.Title,
                FindAnApprenticeshipUrl = _externalLinks.FindAnApprenticeshipUrl,
                ApplicationMethod       = vacancy.ApplicationMethod,
                ApplicationInstructions = vacancy.ApplicationInstructions,
                ApplicationUrl          = vacancy.ApplicationUrl
            };

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

            return(vm);
        }
Exemple #25
0
        public async Task <QualificationsViewModel> GetQualificationsViewModelAsync(VacancyRouteModel vrm)
        {
            var vacancy = await Utility.GetAuthorisedVacancyForEditAsync(_client, _vacancyClient, vrm, RouteNames.Qualifications_Get);

            var allQualifications = await _vacancyClient.GetCandidateQualificationsAsync();

            var vm = new QualificationsViewModel
            {
                Title = vacancy.Title,
                QualificationTypes = allQualifications,
                Qualifications     = vacancy.Qualifications.SortQualifications(allQualifications).ToViewModel().ToList()
            };

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

            return(vm);
        }
        public async Task <EmployerNameViewModel> GetEmployerNameViewModelAsync(
            VacancyRouteModel vrm, VacancyEmployerInfoModel employerInfoModel, VacancyUser user)
        {
            var vacancy = await Utility.GetAuthorisedVacancyForEditAsync(
                _providerVacancyClient, _recruitVacancyClient, vrm, RouteNames.EmployerName_Get);

            var accountLegalEntityPublicHashedId = employerInfoModel.AccountLegalEntityPublicHashedId;

            var getVacancyEditInfoTask = _providerVacancyClient.GetProviderEditVacancyInfoAsync(vrm.Ukprn);

            var getEmployerProfileTask = _recruitVacancyClient.GetEmployerProfileAsync(vacancy.EmployerAccountId, accountLegalEntityPublicHashedId);

            await Task.WhenAll(getVacancyEditInfoTask, getEmployerProfileTask);

            var employerInfo    = getVacancyEditInfoTask.Result.Employers.Single(e => e.EmployerAccountId == vacancy.EmployerAccountId);
            var employerProfile = getEmployerProfileTask.Result;

            var legalEntity = employerInfo.LegalEntities.Single(l => l.AccountLegalEntityPublicHashedId == accountLegalEntityPublicHashedId);

            var vm = new EmployerNameViewModel
            {
                HasOnlyOneOrganisation = employerInfo.LegalEntities.Count() == 1,
                LegalEntityName        = legalEntity.Name,
                ExistingTradingName    = employerProfile?.TradingName,
                PageInfo = Utility.GetPartOnePageInfo(vacancy),
                SelectedEmployerIdentityOption = employerInfoModel.EmployerIdentityOption,
                NewTradingName  = employerInfoModel.NewTradingName,
                AnonymousName   = employerInfoModel.AnonymousName,
                AnonymousReason = employerInfoModel.AnonymousReason
            };

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

            return(vm);
        }
        public async Task <TitleViewModel> GetTitleViewModelAsync(VacancyRouteModel vrm)
        {
            var dashboard = await _client.GetDashboardAsync(vrm.EmployerAccountId);

            var vacancy = await _utility.GetAuthorisedVacancyForEditAsync(vrm, RouteNames.Title_Get);

            var vm = new TitleViewModel
            {
                VacancyId             = vacancy.Id,
                Title                 = vacancy.Title,
                PageInfo              = _utility.GetPartOnePageInfo(vacancy),
                HasCloneableVacancies = dashboard.CloneableVacancies.Any()
            };

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

            return(vm);
        }
Exemple #28
0
        public async Task <WageViewModel> GetWageViewModelAsync(VacancyRouteModel vrm)
        {
            var vacancy = await Utility.GetAuthorisedVacancyForEditAsync(_client, _vacancyClient, vrm, RouteNames.Wage_Get);

            var vm = new WageViewModel
            {
                Duration                  = vacancy.Wage?.Duration?.ToString(),
                DurationUnit              = vacancy.Wage?.DurationUnit ?? DurationUnit.Year,
                WorkingWeekDescription    = vacancy.Wage?.WorkingWeekDescription,
                WeeklyHours               = $"{vacancy.Wage?.WeeklyHours:0.##}",
                WageType                  = vacancy.Wage?.WageType,
                FixedWageYearlyAmount     = vacancy.Wage?.FixedWageYearlyAmount?.AsMoney(),
                WageAdditionalInformation = vacancy.Wage?.WageAdditionalInformation,
                PageInfo                  = Utility.GetPartOnePageInfo(vacancy)
            };

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

            return(vm);
        }
        public async Task <ReviewViewModel> Map(VacancyReview review)
        {
            var vacancy = review.VacancySnapshot;

            var currentVacancy = _vacancyClient.GetVacancyAsync(review.VacancyReference);

            var programmeTask = _vacancyClient.GetApprenticeshipProgrammeAsync(vacancy.ProgrammeId);

            var reviewHistoryTask = _vacancyClient.GetVacancyReviewHistoryAsync(review.VacancyReference);

            var approvedCountTask = _vacancyClient.GetApprovedCountAsync(vacancy.SubmittedByUser.UserId);

            var approvedFirstTimeCountTask = _vacancyClient.GetApprovedFirstTimeCountAsync(vacancy.SubmittedByUser.UserId);

            var reviewSummaryTask = _reviewSummaryService.GetReviewSummaryViewModelAsync(review.Id,
                                                                                         ReviewFieldMappingLookups.GetPreviewReviewFieldIndicators());

            var anonymousApprovedCountTask = vacancy.IsAnonymous ? _vacancyClient.GetAnonymousApprovedCountAsync(vacancy.LegalEntityId) : Task.FromResult(0);

            await Task.WhenAll(
                currentVacancy, programmeTask,
                approvedCountTask,
                approvedFirstTimeCountTask,
                reviewHistoryTask,
                reviewSummaryTask,
                anonymousApprovedCountTask);

            var programme = programmeTask.Result;

            var currentVacancyResult = currentVacancy.Result;

            var historiesVm = GetReviewHistoriesViewModel(reviewHistoryTask.Result);

            var vm = new ReviewViewModel();

            vm.Review = reviewSummaryTask.Result;
            try
            {
                vm.SubmittedByName         = vacancy.SubmittedByUser.Name;
                vm.SubmittedByEmail        = vacancy.SubmittedByUser.Email;
                vm.ApplicationInstructions = vacancy.ApplicationInstructions;
                vm.ApplicationMethod       = vacancy.ApplicationMethod.Value;
                vm.ApplicationUrl          = vacancy.ApplicationUrl;
                vm.ClosingDate             = vacancy.ClosingDate?.AsGdsDate();
                vm.EducationLevelName      =
                    EducationLevelNumberHelper.GetEducationLevelNameOrDefault(programme.EducationLevelNumber, programme.Level);
                vm.EmployerContactName      = vacancy.EmployerContact?.Name;
                vm.EmployerContactEmail     = vacancy.EmployerContact?.Email;
                vm.EmployerContactTelephone = vacancy.EmployerContact?.Phone;
                vm.EmployerDescription      = vacancy.EmployerDescription;
                vm.EmployerName             = vacancy.EmployerName;
                vm.EmployerNameOption       = vacancy.EmployerNameOption.Value;
                vm.AnonymousReason          = vacancy.AnonymousReason;
                vm.AnonymousApprovedCount   = anonymousApprovedCountTask.Result;
                vm.EmployerWebsiteUrl       = vacancy.EmployerWebsiteUrl;
                vm.MapUrl = MapImageHelper.GetEmployerLocationMapUrl(vacancy, _mapService, MapImageWidth, MapImageHeight);
                vm.EmployerAddressElements  = vacancy.EmployerAddressForDisplay();
                vm.LegalEntityName          = vacancy.LegalEntityName;
                vm.IsDisabilityConfident    = vacancy.IsDisabilityConfident;
                vm.NumberOfPositionsCaption = $"{"position".ToQuantity(vacancy.NumberOfPositions.Value)} available";
                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(_qualifications.Value).AsText();
                vm.ShortDescription         = vacancy.ShortDescription;
                vm.Skills                 = vacancy.Skills ?? Enumerable.Empty <string>();
                vm.OwnerType              = vacancy.OwnerType;
                vm.ThingsToConsider       = vacancy.ThingsToConsider;
                vm.Title                  = vacancy.Title;
                vm.TrainingDescription    = vacancy.TrainingDescription;
                vm.VacancyDescription     = vacancy.Description;
                vm.VacancyReferenceNumber = $"VAC{vacancy.VacancyReference}";
                vm.TrainingTitle          = programme.Title;
                vm.TrainingType           = programme.ApprenticeshipType.GetDisplayName();
                vm.TrainingLevel          = programme.Level.GetDisplayName();
                vm.Level                  = programme.Level;
                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;
                vm.SubmittedDate                        = vacancy.SubmittedDate.Value;
                vm.VacancyReviewsApprovedCount          = approvedCountTask.Result;
                vm.VacancyReviewsApprovedFirstTimeCount = approvedFirstTimeCountTask.Result;

                vm.FieldIdentifiers = await GetFieldIdentifiersViewModel(review);

                vm.ReviewerComment = review.ManualQaComment;
                vm.ReviewHistories = historiesVm;
                vm.IsResubmission  = review.SubmissionCount > 1;

                vm.ReviewerName = review.ReviewedByUser.Name;
                vm.ReviewedDate = review.ReviewedDate.GetValueOrDefault();

                vm.ManualOutcome = review.ManualOutcome;

                if (review.Status == ReviewStatus.Closed)
                {
                    vm.PageTitle = GetPageTitle(historiesVm, review.Id, review.ManualOutcome, currentVacancyResult);
                }

                vm.AutomatedQaResults = GetAutomatedQaResultViewModel(review);
                vm.IsVacancyDeleted   = currentVacancyResult.IsDeleted;
            }
            catch (NullReferenceException ex)
            {
                _logger.LogError(ex, "Unable to map vacancy to view model. Unexpected null fields.");
                throw;
            }

            return(vm);
        }