public static ReviewFieldMappingLookupsForPage GetPreviewReviewFieldIndicators() { var vms = new List <ReviewFieldIndicatorViewModel> { new ReviewFieldIndicatorViewModel(FieldIdentifiers.Title, Anchors.Title), new ReviewFieldIndicatorViewModel(FieldIdentifiers.ShortDescription, Anchors.ShortDescription), new ReviewFieldIndicatorViewModel(FieldIdentifiers.ClosingDate, Anchors.ClosingDate), new ReviewFieldIndicatorViewModel(FieldIdentifiers.WorkingWeek, Anchors.WorkingWeek), new ReviewFieldIndicatorViewModel(FieldIdentifiers.Wage, Anchors.YearlyWage), new ReviewFieldIndicatorViewModel(FieldIdentifiers.ExpectedDuration, Anchors.ExpectedDuration), new ReviewFieldIndicatorViewModel(FieldIdentifiers.PossibleStartDate, Anchors.PossibleStartDate), new ReviewFieldIndicatorViewModel(FieldIdentifiers.TrainingLevel, Anchors.TrainingLevel), new ReviewFieldIndicatorViewModel(FieldIdentifiers.NumberOfPositions, Anchors.NumberOfPositions), new ReviewFieldIndicatorViewModel(FieldIdentifiers.VacancyDescription, Anchors.VacancyDescription), new ReviewFieldIndicatorViewModel(FieldIdentifiers.TrainingDescription, Anchors.TrainingDescription), new ReviewFieldIndicatorViewModel(FieldIdentifiers.OutcomeDescription, Anchors.OutcomeDescription), new ReviewFieldIndicatorViewModel(FieldIdentifiers.Skills, Anchors.Skills), new ReviewFieldIndicatorViewModel(FieldIdentifiers.Qualifications, Anchors.Qualifications), new ReviewFieldIndicatorViewModel(FieldIdentifiers.ThingsToConsider, Anchors.ThingsToConsider), new ReviewFieldIndicatorViewModel(FieldIdentifiers.EmployerDescription, Anchors.EmployerDescription), new ReviewFieldIndicatorViewModel(FieldIdentifiers.DisabilityConfident, Anchors.DisabilityConfident), new ReviewFieldIndicatorViewModel(FieldIdentifiers.EmployerWebsiteUrl, Anchors.EmployerWebsiteUrl), new ReviewFieldIndicatorViewModel(FieldIdentifiers.EmployerContact, Anchors.EmployerContact), new ReviewFieldIndicatorViewModel(FieldIdentifiers.EmployerAddress, Anchors.EmployerAddress), new ReviewFieldIndicatorViewModel(FieldIdentifiers.Provider, Anchors.Provider), new ReviewFieldIndicatorViewModel(FieldIdentifiers.Training, Anchors.Training), new ReviewFieldIndicatorViewModel(FieldIdentifiers.ApplicationMethod, Anchors.ApplicationMethod), new ReviewFieldIndicatorViewModel(FieldIdentifiers.ApplicationUrl, Anchors.ApplicationUrl), new ReviewFieldIndicatorViewModel(FieldIdentifiers.ApplicationInstructions, Anchors.ApplicationInstructions) }; var mappings = new Dictionary <string, IEnumerable <string> > { { FieldIdResolver.ToFieldId(v => v.EmployerAccountId), new string[0] }, { FieldIdResolver.ToFieldId(v => v.Title), new[] { FieldIdentifiers.Title } }, { FieldIdResolver.ToFieldId(v => v.EmployerName), new string[0] }, { FieldIdResolver.ToFieldId(v => v.ShortDescription), new [] { FieldIdentifiers.ShortDescription } }, { FieldIdResolver.ToFieldId(v => v.ClosingDate), new [] { FieldIdentifiers.ClosingDate } }, { FieldIdResolver.ToFieldId(v => v.Wage.WeeklyHours), new [] { FieldIdentifiers.WorkingWeek } }, { FieldIdResolver.ToFieldId(v => v.Wage.WorkingWeekDescription), new [] { FieldIdentifiers.WorkingWeek } }, { FieldIdResolver.ToFieldId(v => v.Wage.WageAdditionalInformation), new [] { FieldIdentifiers.Wage } }, { FieldIdResolver.ToFieldId(v => v.Wage.WageType), new[] { FieldIdentifiers.Wage } }, { FieldIdResolver.ToFieldId(v => v.Wage.FixedWageYearlyAmount), new [] { FieldIdentifiers.Wage } }, { FieldIdResolver.ToFieldId(v => v.Wage.Duration), new [] { FieldIdentifiers.ExpectedDuration } }, { FieldIdResolver.ToFieldId(v => v.Wage.DurationUnit), new [] { FieldIdentifiers.ExpectedDuration } }, { FieldIdResolver.ToFieldId(v => v.StartDate), new [] { FieldIdentifiers.PossibleStartDate } }, { FieldIdResolver.ToFieldId(v => v.ProgrammeId), new [] { FieldIdentifiers.TrainingLevel, FieldIdentifiers.Training } }, { FieldIdResolver.ToFieldId(v => v.VacancyReference), new string[0] }, { FieldIdResolver.ToFieldId(v => v.NumberOfPositions), new [] { FieldIdentifiers.NumberOfPositions } }, { FieldIdResolver.ToFieldId(v => v.Description), new [] { FieldIdentifiers.VacancyDescription } }, { FieldIdResolver.ToFieldId(v => v.TrainingDescription), new [] { FieldIdentifiers.TrainingDescription } }, { FieldIdResolver.ToFieldId(v => v.OutcomeDescription), new [] { FieldIdentifiers.OutcomeDescription } }, { FieldIdResolver.ToFieldId(v => v.Skills), new [] { FieldIdentifiers.Skills } }, { FieldIdResolver.ToFieldId(v => v.Qualifications), new [] { FieldIdentifiers.Qualifications } }, { FieldIdResolver.ToFieldId(v => v.ThingsToConsider), new [] { FieldIdentifiers.ThingsToConsider } }, { FieldIdResolver.ToFieldId(v => v.EmployerDescription), new [] { FieldIdentifiers.EmployerDescription } }, { FieldIdResolver.ToFieldId(v => v.DisabilityConfident), new [] { FieldIdentifiers.DisabilityConfident } }, { FieldIdResolver.ToFieldId(v => v.EmployerWebsiteUrl), new [] { FieldIdentifiers.EmployerWebsiteUrl } }, { FieldIdResolver.ToFieldId(v => v.EmployerLocation.AddressLine1), new [] { FieldIdentifiers.EmployerAddress } }, { FieldIdResolver.ToFieldId(v => v.EmployerLocation.AddressLine2), new [] { FieldIdentifiers.EmployerAddress } }, { FieldIdResolver.ToFieldId(v => v.EmployerLocation.AddressLine3), new [] { FieldIdentifiers.EmployerAddress } }, { FieldIdResolver.ToFieldId(v => v.EmployerLocation.AddressLine4), new [] { FieldIdentifiers.EmployerAddress } }, { FieldIdResolver.ToFieldId(v => v.EmployerLocation.Postcode), new[] { FieldIdentifiers.EmployerAddress } }, { FieldIdResolver.ToFieldId(v => v.EmployerContact.Email), new [] { FieldIdentifiers.EmployerContact } }, { FieldIdResolver.ToFieldId(v => v.EmployerContact.Name), new [] { FieldIdentifiers.EmployerContact } }, { FieldIdResolver.ToFieldId(v => v.EmployerContact.Phone), new [] { FieldIdentifiers.EmployerContact } }, { FieldIdResolver.ToFieldId(v => v.TrainingProvider.Ukprn), new [] { FieldIdentifiers.Provider } }, { FieldIdResolver.ToFieldId(v => v.ApplicationInstructions), new [] { FieldIdentifiers.ApplicationInstructions } }, { FieldIdResolver.ToFieldId(v => v.ApplicationMethod), new [] { FieldIdentifiers.ApplicationMethod } }, { FieldIdResolver.ToFieldId(v => v.ApplicationUrl), new [] { FieldIdentifiers.ApplicationUrl } } }; return(new ReviewFieldMappingLookupsForPage(vms, mappings)); }
public async Task <OrchestratorResponse> PostLocationEditModelAsync( LocationEditModel locationEditModel, VacancyEmployerInfoModel employerInfoModel, VacancyUser user) { if (string.IsNullOrEmpty(locationEditModel.SelectedLocation)) { return(new OrchestratorResponse(false)); } var vacancyTask = _utility.GetAuthorisedVacancyForEditAsync(locationEditModel, RouteNames.Employer_Post); var employerVacancyInfoTask = _employerVacancyClient.GetEditVacancyInfoAsync(locationEditModel.EmployerAccountId); await Task.WhenAll(vacancyTask, employerVacancyInfoTask); var vacancy = vacancyTask.Result; var editVacancyInfo = employerVacancyInfoTask.Result; var accountLegalEntityPublicHashedId = !string.IsNullOrEmpty(employerInfoModel?.AccountLegalEntityPublicHashedId) ? employerInfoModel.AccountLegalEntityPublicHashedId : vacancy.AccountLegalEntityPublicHashedId; var selectedOrganisation = editVacancyInfo.LegalEntities.Single(l => l.AccountLegalEntityPublicHashedId == accountLegalEntityPublicHashedId); var employerProfile = await _recruitVacancyClient.GetEmployerProfileAsync(vacancy.EmployerAccountId, selectedOrganisation.AccountLegalEntityPublicHashedId); var allLocations = await GetAllAvailableLocationsAsync(employerProfile); var newLocation = locationEditModel.SelectedLocation == LocationViewModel.UseOtherLocationConst ? locationEditModel.ToAddressString() : locationEditModel.SelectedLocation; var matchingAddress = GetMatchingAddress(newLocation, allLocations); var employerLocation = matchingAddress != null ? matchingAddress : ConvertToDomainAddress(locationEditModel); // this has diverged from the usual pattern because the individual properties are review fields SetVacancyWithEmployerReviewFieldIndicators( vacancy.EmployerLocation?.AddressLine1, FieldIdResolver.ToFieldId(v => v.EmployerLocation.AddressLine1), vacancy, (v) => { return(employerLocation.AddressLine1); }); SetVacancyWithEmployerReviewFieldIndicators( vacancy.EmployerLocation?.AddressLine2, FieldIdResolver.ToFieldId(v => v.EmployerLocation.AddressLine2), vacancy, (v) => { return(employerLocation.AddressLine2); }); SetVacancyWithEmployerReviewFieldIndicators( vacancy.EmployerLocation?.AddressLine3, FieldIdResolver.ToFieldId(v => v.EmployerLocation.AddressLine3), vacancy, (v) => { return(employerLocation.AddressLine3); }); SetVacancyWithEmployerReviewFieldIndicators( vacancy.EmployerLocation?.AddressLine4, FieldIdResolver.ToFieldId(v => v.EmployerLocation.AddressLine4), vacancy, (v) => { return(employerLocation.AddressLine4); }); SetVacancyWithEmployerReviewFieldIndicators( vacancy.EmployerLocation?.Postcode, FieldIdResolver.ToFieldId(v => v.EmployerLocation.Postcode), vacancy, (v) => { return(employerLocation.Postcode); }); vacancy.EmployerLocation = employerLocation; // if cookie is found then update legal entity and name option from cookie if (employerInfoModel != null) { SetVacancyWithEmployerReviewFieldIndicators( vacancy.LegalEntityName, FieldIdResolver.ToFieldId(v => v.EmployerName), vacancy, (v) => { return(v.LegalEntityName = selectedOrganisation.Name); }); SetVacancyWithEmployerReviewFieldIndicators( vacancy.EmployerNameOption, FieldIdResolver.ToFieldId(v => v.EmployerName), vacancy, (v) => { return(v.EmployerNameOption = employerInfoModel.EmployerIdentityOption?.ConvertToDomainOption()); }); if (employerInfoModel.EmployerIdentityOption == EmployerIdentityOption.NewTradingName) { SetVacancyWithEmployerReviewFieldIndicators( employerProfile.TradingName, FieldIdResolver.ToFieldId(v => v.EmployerName), vacancy, (e) => { // the indicator will be set for the vacancy when the employer profile will change to the new trading name return(employerInfoModel.NewTradingName); }); } vacancy.AccountLegalEntityPublicHashedId = selectedOrganisation.AccountLegalEntityPublicHashedId; vacancy.AnonymousReason = vacancy.IsAnonymous ? employerInfoModel.AnonymousReason : null; vacancy.EmployerName = vacancy.IsAnonymous ? employerInfoModel.AnonymousName : null; } return(await ValidateAndExecute( vacancy, v => _recruitVacancyClient.Validate(v, ValidationRules), async v => { await _recruitVacancyClient.UpdateDraftVacancyAsync(vacancy, user); await UpdateEmployerProfile(employerInfoModel, employerProfile, matchingAddress == null ? vacancy.EmployerLocation : null, user); })); }