public async Task <OrchestratorResponse> PostConsiderationsEditModelAsync(ConsiderationsEditModel m, VacancyUser user) { var vacancy = await Utility.GetAuthorisedVacancyForEditAsync(_client, _vacancyClient, m, RouteNames.Considerations_Post); SetVacancyWithProviderReviewFieldIndicators( vacancy.ThingsToConsider, FieldIdResolver.ToFieldId(v => v.ThingsToConsider), vacancy, (v) => { return(v.ThingsToConsider = m.ThingsToConsider); }); return(await ValidateAndExecute( vacancy, v => _vacancyClient.Validate(v, ValidationRules), v => _vacancyClient.UpdateDraftVacancyAsync(vacancy, user) )); }
public static ReviewFieldMappingLookupsForPage GetAboutEmployerFieldIndicators() { var vms = new List <ReviewFieldIndicatorViewModel> { new ReviewFieldIndicatorViewModel(FieldIdentifiers.EmployerDescription, nameof(AboutEmployerEditModel.EmployerDescription)), new ReviewFieldIndicatorViewModel(FieldIdentifiers.EmployerWebsiteUrl, nameof(AboutEmployerEditModel.EmployerWebsiteUrl)) }; var mappings = new Dictionary <string, IEnumerable <string> > { { FieldIdResolver.ToFieldId(v => v.EmployerDescription), new [] { FieldIdentifiers.EmployerDescription } }, { FieldIdResolver.ToFieldId(v => v.EmployerWebsiteUrl), new [] { FieldIdentifiers.EmployerWebsiteUrl } } }; return(new ReviewFieldMappingLookupsForPage(vms, mappings)); }
public static ReviewFieldMappingLookupsForPage GetEmployerContactDetailsFieldIndicators() { var vms = new List <ReviewFieldIndicatorViewModel> { new ReviewFieldIndicatorViewModel(FieldIdentifiers.EmployerContact, nameof(EmployerContactDetailsEditModel.EmployerContactName)), }; var mappings = new Dictionary <string, IEnumerable <string> > { { 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 } } }; return(new ReviewFieldMappingLookupsForPage(vms, mappings)); }
public static ReviewFieldMappingLookupsForPage GetTitleFieldIndicators() { var vms = new List <ReviewFieldIndicatorViewModel> { new ReviewFieldIndicatorViewModel(FieldIdentifiers.Title, nameof(TitleEditModel.Title)), new ReviewFieldIndicatorViewModel(FieldIdentifiers.NumberOfPositions, nameof(TitleEditModel.NumberOfPositions)) }; var mappings = new Dictionary <string, IEnumerable <string> > { { FieldIdResolver.ToFieldId(v => v.Title), new[] { FieldIdentifiers.Title } }, { FieldIdResolver.ToFieldId(v => v.NumberOfPositions), new [] { FieldIdentifiers.NumberOfPositions } } }; return(new ReviewFieldMappingLookupsForPage(vms, mappings)); }
public VacancyComparerResult Compare(Vacancy a, Vacancy b) { var fields = new List <VacancyComparerField> { CompareValue(a, b, v => v.VacancyReference, FieldIdResolver.ToFieldId(v => v.VacancyReference)), CompareValue(a, b, v => v.EmployerAccountId, FieldIdResolver.ToFieldId(v => v.EmployerAccountId)), CompareValue(a, b, v => v.ApplicationInstructions, FieldIdResolver.ToFieldId(v => v.ApplicationInstructions)), CompareValue(a, b, v => v.ApplicationMethod, FieldIdResolver.ToFieldId(v => v.ApplicationMethod)), CompareValue(a, b, v => v.ApplicationUrl, FieldIdResolver.ToFieldId(v => v.ApplicationUrl)), CompareValue(a, b, v => v.ClosingDate, FieldIdResolver.ToFieldId(v => v.ClosingDate)), CompareValue(a, b, v => v.Description, FieldIdResolver.ToFieldId(v => v.Description)), CompareValue(a, b, v => v.DisabilityConfident, FieldIdResolver.ToFieldId(v => v.DisabilityConfident)), CompareValue(a, b, v => v.EmployerContact?.Email, FieldIdResolver.ToFieldId(v => v.EmployerContact.Email)), CompareValue(a, b, v => v.EmployerContact?.Name, FieldIdResolver.ToFieldId(v => v.EmployerContact.Name)), CompareValue(a, b, v => v.EmployerContact?.Phone, FieldIdResolver.ToFieldId(v => v.EmployerContact.Phone)), CompareValue(a, b, v => v.EmployerDescription, FieldIdResolver.ToFieldId(v => v.EmployerDescription)), CompareValue(a, b, v => v.EmployerLocation?.AddressLine1, FieldIdResolver.ToFieldId(v => v.EmployerLocation.AddressLine1)), CompareValue(a, b, v => v.EmployerLocation?.AddressLine2, FieldIdResolver.ToFieldId(v => v.EmployerLocation.AddressLine2)), CompareValue(a, b, v => v.EmployerLocation?.AddressLine3, FieldIdResolver.ToFieldId(v => v.EmployerLocation.AddressLine3)), CompareValue(a, b, v => v.EmployerLocation?.AddressLine4, FieldIdResolver.ToFieldId(v => v.EmployerLocation.AddressLine4)), CompareValue(a, b, v => v.EmployerLocation?.Postcode, FieldIdResolver.ToFieldId(v => v.EmployerLocation.Postcode)), CompareValue(a, b, v => v.EmployerName, FieldIdResolver.ToFieldId(v => v.EmployerName)), CompareValue(a, b, v => v.EmployerWebsiteUrl, FieldIdResolver.ToFieldId(v => v.EmployerWebsiteUrl)), CompareValue(a, b, v => v.NumberOfPositions, FieldIdResolver.ToFieldId(v => v.NumberOfPositions)), CompareValue(a, b, v => v.OutcomeDescription, FieldIdResolver.ToFieldId(v => v.OutcomeDescription)), CompareValue(a, b, v => v.ProgrammeId, FieldIdResolver.ToFieldId(v => v.ProgrammeId)), CompareList(a, b, v => v.Qualifications, FieldIdResolver.ToFieldId(v => v.Qualifications)), CompareValue(a, b, v => v.ShortDescription, FieldIdResolver.ToFieldId(v => v.ShortDescription)), CompareList(a, b, v => v.Skills, FieldIdResolver.ToFieldId(v => v.Skills)), CompareValue(a, b, v => v.StartDate, FieldIdResolver.ToFieldId(v => v.StartDate)), CompareValue(a, b, v => v.ThingsToConsider, FieldIdResolver.ToFieldId(v => v.ThingsToConsider)), CompareValue(a, b, v => v.Title, FieldIdResolver.ToFieldId(v => v.Title)), CompareValue(a, b, v => v.TrainingDescription, FieldIdResolver.ToFieldId(v => v.TrainingDescription)), CompareValue(a, b, v => v.TrainingProvider?.Ukprn, FieldIdResolver.ToFieldId(v => v.TrainingProvider.Ukprn)), CompareValue(a, b, v => v.Wage?.WeeklyHours, FieldIdResolver.ToFieldId(v => v.Wage.WeeklyHours)), CompareValue(a, b, v => v.Wage?.WorkingWeekDescription, FieldIdResolver.ToFieldId(v => v.Wage.WorkingWeekDescription)), CompareValue(a, b, v => v.Wage?.WageAdditionalInformation, FieldIdResolver.ToFieldId(v => v.Wage.WageAdditionalInformation)), CompareValue(a, b, v => v.Wage?.WageType, FieldIdResolver.ToFieldId(v => v.Wage.WageType)), CompareValue(a, b, v => v.Wage?.FixedWageYearlyAmount, FieldIdResolver.ToFieldId(v => v.Wage.FixedWageYearlyAmount)), CompareValue(a, b, v => v.Wage?.Duration, FieldIdResolver.ToFieldId(v => v.Wage.Duration)), CompareValue(a, b, v => v.Wage?.DurationUnit, FieldIdResolver.ToFieldId(v => v.Wage.DurationUnit)) }; return(new VacancyComparerResult { Fields = fields }); }
public static ReviewFieldMappingLookupsForPage GetWageReviewFieldIndicators() { var vms = new List <ReviewFieldIndicatorViewModel> { new ReviewFieldIndicatorViewModel(FieldIdentifiers.Wage, Anchors.WageTypeHeading), new ReviewFieldIndicatorViewModel(FieldIdentifiers.WageAdditionalInfo, nameof(WageEditModel.WageAdditionalInformation)) }; var mappings = new Dictionary <string, IEnumerable <string> > { { FieldIdResolver.ToFieldId(v => v.Wage.WageAdditionalInformation), new [] { FieldIdentifiers.WageAdditionalInfo } }, { FieldIdResolver.ToFieldId(v => v.Wage.WageType), new[] { FieldIdentifiers.Wage } }, { FieldIdResolver.ToFieldId(v => v.Wage.FixedWageYearlyAmount), new [] { FieldIdentifiers.Wage } } }; return(new ReviewFieldMappingLookupsForPage(vms, mappings)); }
public async Task <OrchestratorResponse <Guid> > PostTitleEditModelAsync(TitleEditModel m, VacancyUser user) { TrainingProvider provider = null; IApprenticeshipProgramme programme = null; if (!m.VacancyId.HasValue) // Create if it's a new vacancy { var newVacancy = new Vacancy { Title = m.Title }; return(await ValidateAndExecute( newVacancy, v => _vacancyClient.Validate(v, ValidationRules), async v => { if (m.ReferredFromSavedFavourites) { provider = await GetProvider(m.ReferredUkprn); programme = await GetProgramme(m.ReferredProgrammeId); } return await _client.CreateVacancyAsync(m.Title, m.EmployerAccountId, user, provider, programme?.Id); })); } var vacancy = await _utility.GetAuthorisedVacancyForEditAsync(new VacancyRouteModel { EmployerAccountId = m.EmployerAccountId, VacancyId = m.VacancyId.Value }, RouteNames.Title_Post); SetVacancyWithEmployerReviewFieldIndicators( vacancy.Title, FieldIdResolver.ToFieldId(v => v.Title), vacancy, (v) => { return(v.Title = m.Title); }); return(await ValidateAndExecute( vacancy, v => _vacancyClient.Validate(v, ValidationRules), async v => { await _vacancyClient.UpdateDraftVacancyAsync(vacancy, user); return v.Id; } )); }
public static ReviewFieldMappingLookupsForPage GetDurationReviewFieldIndicators() { var vms = new List <ReviewFieldIndicatorViewModel> { new ReviewFieldIndicatorViewModel(FieldIdentifiers.ExpectedDuration, nameof(DurationEditModel.Duration)), new ReviewFieldIndicatorViewModel(FieldIdentifiers.WorkingWeek, nameof(DurationEditModel.WorkingWeekDescription)) }; var mappings = new Dictionary <string, IEnumerable <string> > { { FieldIdResolver.ToFieldId(v => v.Wage.WeeklyHours), new [] { FieldIdentifiers.WorkingWeek } }, { FieldIdResolver.ToFieldId(v => v.Wage.WorkingWeekDescription), new [] { FieldIdentifiers.WorkingWeek } }, { FieldIdResolver.ToFieldId(v => v.Wage.Duration), new [] { FieldIdentifiers.ExpectedDuration } }, { FieldIdResolver.ToFieldId(v => v.Wage.DurationUnit), new [] { FieldIdentifiers.ExpectedDuration } } }; return(new ReviewFieldMappingLookupsForPage(vms, mappings)); }
public static ReviewFieldMappingLookupsForPage GetDatesReviewFieldIndicators() { var vms = new List <ReviewFieldIndicatorViewModel> { new ReviewFieldIndicatorViewModel(FieldIdentifiers.ClosingDate, nameof(DatesEditModel.ClosingDay)), new ReviewFieldIndicatorViewModel(FieldIdentifiers.PossibleStartDate, nameof(DatesEditModel.StartDay)), new ReviewFieldIndicatorViewModel(FieldIdentifiers.DisabilityConfident, nameof(DatesEditModel.IsDisabilityConfident)) }; var mappings = new Dictionary <string, IEnumerable <string> > { { FieldIdResolver.ToFieldId(v => v.ClosingDate), new [] { FieldIdentifiers.ClosingDate } }, { FieldIdResolver.ToFieldId(v => v.StartDate), new [] { FieldIdentifiers.PossibleStartDate } }, { FieldIdResolver.ToFieldId(v => v.DisabilityConfident), new [] { FieldIdentifiers.DisabilityConfident } } }; return(new ReviewFieldMappingLookupsForPage(vms, mappings)); }
public static ReviewFieldMappingLookupsForPage GetVacancyDescriptionFieldIndicators() { var vms = new List <ReviewFieldIndicatorViewModel> { new ReviewFieldIndicatorViewModel(FieldIdentifiers.VacancyDescription, nameof(VacancyDescriptionEditModel.VacancyDescription)), new ReviewFieldIndicatorViewModel(FieldIdentifiers.TrainingDescription, nameof(VacancyDescriptionEditModel.TrainingDescription)), new ReviewFieldIndicatorViewModel(FieldIdentifiers.OutcomeDescription, nameof(VacancyDescriptionEditModel.OutcomeDescription)), }; var mappings = new Dictionary <string, IEnumerable <string> > { { FieldIdResolver.ToFieldId(v => v.Description), new [] { FieldIdentifiers.VacancyDescription } }, { FieldIdResolver.ToFieldId(v => v.TrainingDescription), new [] { FieldIdentifiers.TrainingDescription } }, { FieldIdResolver.ToFieldId(v => v.OutcomeDescription), new [] { FieldIdentifiers.OutcomeDescription } } }; return(new ReviewFieldMappingLookupsForPage(vms, mappings)); }
public static ReviewFieldMappingLookupsForPage GetApplicationProcessFieldIndicators() { var vms = new List <ReviewFieldIndicatorViewModel> { new ReviewFieldIndicatorViewModel(FieldIdentifiers.ApplicationMethod, Anchors.ApplicationMethodHeading), new ReviewFieldIndicatorViewModel(FieldIdentifiers.ApplicationUrl, nameof(ApplicationProcessEditModel.ApplicationUrl)), new ReviewFieldIndicatorViewModel(FieldIdentifiers.ApplicationInstructions, nameof(ApplicationProcessEditModel.ApplicationInstructions)) }; var mappings = new Dictionary <string, IEnumerable <string> > { { 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 static ReviewFieldMappingLookupsForPage GetTrainingReviewFieldIndicators() { var vms = new List <ReviewFieldIndicatorViewModel> { new ReviewFieldIndicatorViewModel(FieldIdentifiers.Training, nameof(TrainingEditModel.SelectedProgrammeId)), new ReviewFieldIndicatorViewModel(FieldIdentifiers.TrainingLevel, nameof(TrainingEditModel.SelectedProgrammeId)) }; var mappings = new Dictionary <string, IEnumerable <string> > { { FieldIdResolver.ToFieldId(v => v.ClosingDate), new [] { FieldIdentifiers.ClosingDate } }, { FieldIdResolver.ToFieldId(v => v.StartDate), new [] { FieldIdentifiers.PossibleStartDate } }, { FieldIdResolver.ToFieldId(v => v.ProgrammeId), new [] { FieldIdentifiers.TrainingLevel, FieldIdentifiers.Training } }, { FieldIdResolver.ToFieldId(v => v.DisabilityConfident), new [] { FieldIdentifiers.DisabilityConfident } } }; return(new ReviewFieldMappingLookupsForPage(vms, mappings)); }
public async Task <OrchestratorResponse> PostConfirmTrainingEditModelAsync(ConfirmTrainingEditModel m, VacancyUser user) { var vacancy = await _utility.GetAuthorisedVacancyForEditAsync(m, RouteNames.Training_Confirm_Post); SetVacancyWithEmployerReviewFieldIndicators( vacancy.ProgrammeId, FieldIdResolver.ToFieldId(v => v.ProgrammeId), vacancy, (v) => { return(v.ProgrammeId = m.ProgrammeId); }); return(await ValidateAndExecute( vacancy, v => _vacancyClient.Validate(v, ValidationRules), v => _vacancyClient.UpdateDraftVacancyAsync(vacancy, user) )); }
public async Task <OrchestratorResponse> PostShortDescriptionEditModelAsync(ShortDescriptionEditModel m, VacancyUser user) { var vacancy = await _utility.GetAuthorisedVacancyForEditAsync(m, RouteNames.ShortDescription_Post); SetVacancyWithEmployerReviewFieldIndicators( vacancy.ShortDescription, FieldIdResolver.ToFieldId(v => v.ShortDescription), vacancy, (v) => { return(v.ShortDescription = m.ShortDescription); }); return(await ValidateAndExecute( vacancy, v => _vacancyClient.Validate(v, ValidationRules), v => _vacancyClient.UpdateDraftVacancyAsync(vacancy, user) )); }
public async Task <OrchestratorResponse <Guid> > PostTitleEditModelAsync(VacancyRouteModel vrm, TitleEditModel model, VacancyUser user, long ukprn) { if (model.VacancyId.HasValue) { var vacancy = await Utility.GetAuthorisedVacancyForEditAsync(_providerVacancyClient, _recruitVacancyClient, vrm, RouteNames.Title_Post); SetVacancyWithProviderReviewFieldIndicators( vacancy.Title, FieldIdResolver.ToFieldId(v => v.Title), vacancy, (v) => { return(v.Title = model.Title); }); return(await ValidateAndExecute( vacancy, v => _recruitVacancyClient.Validate(v, ValidationRules), async v => { await _recruitVacancyClient.UpdateDraftVacancyAsync(vacancy, user); return v.Id; } )); } await ValidateEmployerAccountIdAsync(ukprn, model.EmployerAccountId); var newVacancy = new Vacancy { TrainingProvider = new TrainingProvider { Ukprn = ukprn }, Title = model.Title }; return(await ValidateAndExecute( newVacancy, v => _recruitVacancyClient.Validate(v, ValidationRules), async v => await _providerVacancyClient.CreateVacancyAsync( model.EmployerAccountId, ukprn, model.Title, user))); }
public async Task <OrchestratorResponse> PostWageEditModelAsync(WageEditModel m, VacancyUser user) { var vacancy = await Utility.GetAuthorisedVacancyForEditAsync(_client, _vacancyClient, m, RouteNames.Wage_Post); if (vacancy.Wage == null) { vacancy.Wage = new Wage(); } SetVacancyWithProviderReviewFieldIndicators( vacancy.Wage.WageType, FieldIdResolver.ToFieldId(v => v.Wage.WageType), vacancy, (v) => { return(v.Wage.WageType = m.WageType); }); SetVacancyWithProviderReviewFieldIndicators( vacancy.Wage.FixedWageYearlyAmount, FieldIdResolver.ToFieldId(v => v.Wage.FixedWageYearlyAmount), vacancy, (v) => { return(v.Wage.FixedWageYearlyAmount = (m.WageType == WageType.FixedWage) ? m.FixedWageYearlyAmount?.AsMoney() : null); }); SetVacancyWithProviderReviewFieldIndicators( vacancy.Wage.WageAdditionalInformation, FieldIdResolver.ToFieldId(v => v.Wage.WageAdditionalInformation), vacancy, (v) => { return(v.Wage.WageAdditionalInformation = m.WageAdditionalInformation); }); return(await ValidateAndExecute( vacancy, v => _vacancyClient.Validate(v, ValidationRules), v => _vacancyClient.UpdateDraftVacancyAsync(vacancy, user) )); }
public void ShouldCompare(Vacancy a, Vacancy b, bool expectedAreEqual) { var sut = new VacancyComparerService(); var result = sut.Compare(a, b); result.Fields.Single(f => f.FieldName == FieldIdResolver.ToFieldId(v => v.VacancyReference)).AreEqual.Should().Be(expectedAreEqual); result.Fields.Single(f => f.FieldName == FieldIdResolver.ToFieldId(v => v.EmployerAccountId)).AreEqual.Should().Be(expectedAreEqual); result.Fields.Single(f => f.FieldName == FieldIdResolver.ToFieldId(v => v.ApplicationInstructions)).AreEqual.Should().Be(expectedAreEqual); result.Fields.Single(f => f.FieldName == FieldIdResolver.ToFieldId(v => v.ApplicationMethod)).AreEqual.Should().Be(expectedAreEqual); result.Fields.Single(f => f.FieldName == FieldIdResolver.ToFieldId(v => v.ApplicationUrl)).AreEqual.Should().Be(expectedAreEqual); result.Fields.Single(f => f.FieldName == FieldIdResolver.ToFieldId(v => v.ClosingDate)).AreEqual.Should().Be(expectedAreEqual); result.Fields.Single(f => f.FieldName == FieldIdResolver.ToFieldId(v => v.Description)).AreEqual.Should().Be(expectedAreEqual); result.Fields.Single(f => f.FieldName == FieldIdResolver.ToFieldId(v => v.DisabilityConfident)).AreEqual.Should().Be(expectedAreEqual); result.Fields.Single(f => f.FieldName == FieldIdResolver.ToFieldId(v => v.EmployerContact.Email)).AreEqual.Should().Be(expectedAreEqual); result.Fields.Single(f => f.FieldName == FieldIdResolver.ToFieldId(v => v.EmployerContact.Name)).AreEqual.Should().Be(expectedAreEqual); result.Fields.Single(f => f.FieldName == FieldIdResolver.ToFieldId(v => v.EmployerContact.Phone)).AreEqual.Should().Be(expectedAreEqual); result.Fields.Single(f => f.FieldName == FieldIdResolver.ToFieldId(v => v.EmployerDescription)).AreEqual.Should().Be(expectedAreEqual); result.Fields.Single(f => f.FieldName == FieldIdResolver.ToFieldId(v => v.EmployerLocation.AddressLine1)).AreEqual.Should().Be(expectedAreEqual); result.Fields.Single(f => f.FieldName == FieldIdResolver.ToFieldId(v => v.EmployerLocation.AddressLine2)).AreEqual.Should().Be(expectedAreEqual); result.Fields.Single(f => f.FieldName == FieldIdResolver.ToFieldId(v => v.EmployerLocation.AddressLine3)).AreEqual.Should().Be(expectedAreEqual); result.Fields.Single(f => f.FieldName == FieldIdResolver.ToFieldId(v => v.EmployerLocation.AddressLine4)).AreEqual.Should().Be(expectedAreEqual); result.Fields.Single(f => f.FieldName == FieldIdResolver.ToFieldId(v => v.EmployerLocation.Postcode)).AreEqual.Should().Be(expectedAreEqual); result.Fields.Single(f => f.FieldName == FieldIdResolver.ToFieldId(v => v.EmployerName)).AreEqual.Should().Be(expectedAreEqual); result.Fields.Single(f => f.FieldName == FieldIdResolver.ToFieldId(v => v.EmployerWebsiteUrl)).AreEqual.Should().Be(expectedAreEqual); result.Fields.Single(f => f.FieldName == FieldIdResolver.ToFieldId(v => v.NumberOfPositions)).AreEqual.Should().Be(expectedAreEqual); result.Fields.Single(f => f.FieldName == FieldIdResolver.ToFieldId(v => v.OutcomeDescription)).AreEqual.Should().Be(expectedAreEqual); result.Fields.Single(f => f.FieldName == FieldIdResolver.ToFieldId(v => v.ProgrammeId)).AreEqual.Should().Be(expectedAreEqual); result.Fields.Single(f => f.FieldName == FieldIdResolver.ToFieldId(v => v.ShortDescription)).AreEqual.Should().Be(expectedAreEqual); result.Fields.Single(f => f.FieldName == FieldIdResolver.ToFieldId(v => v.StartDate)).AreEqual.Should().Be(expectedAreEqual); result.Fields.Single(f => f.FieldName == FieldIdResolver.ToFieldId(v => v.ThingsToConsider)).AreEqual.Should().Be(expectedAreEqual); result.Fields.Single(f => f.FieldName == FieldIdResolver.ToFieldId(v => v.Title)).AreEqual.Should().Be(expectedAreEqual); result.Fields.Single(f => f.FieldName == FieldIdResolver.ToFieldId(v => v.TrainingDescription)).AreEqual.Should().Be(expectedAreEqual); result.Fields.Single(f => f.FieldName == FieldIdResolver.ToFieldId(v => v.TrainingProvider.Ukprn)).AreEqual.Should().Be(expectedAreEqual); result.Fields.Single(f => f.FieldName == FieldIdResolver.ToFieldId(v => v.Wage.WeeklyHours)).AreEqual.Should().Be(expectedAreEqual); result.Fields.Single(f => f.FieldName == FieldIdResolver.ToFieldId(v => v.Wage.WorkingWeekDescription)).AreEqual.Should().Be(expectedAreEqual); result.Fields.Single(f => f.FieldName == FieldIdResolver.ToFieldId(v => v.Wage.WageAdditionalInformation)).AreEqual.Should().Be(expectedAreEqual); result.Fields.Single(f => f.FieldName == FieldIdResolver.ToFieldId(v => v.Wage.WageType)).AreEqual.Should().Be(expectedAreEqual); result.Fields.Single(f => f.FieldName == FieldIdResolver.ToFieldId(v => v.Wage.FixedWageYearlyAmount)).AreEqual.Should().Be(expectedAreEqual); result.Fields.Single(f => f.FieldName == FieldIdResolver.ToFieldId(v => v.Wage.Duration)).AreEqual.Should().Be(expectedAreEqual); }
public async Task DeleteQualificationAsync(VacancyRouteModel vrm, int index, VacancyUser user) { var vacancy = await _utility.GetAuthorisedVacancyForEditAsync(vrm, RouteNames.Qualifications_Get); if (vacancy.Qualifications == null) { return; } SetVacancyWithEmployerReviewFieldIndicators( vacancy.Qualifications[index], FieldIdResolver.ToFieldId(v => v.Qualifications), vacancy, (v) => { vacancy.Qualifications.RemoveAt(index); return(null); }); await _vacancyClient.UpdateDraftVacancyAsync(vacancy, user); }
public async Task <OrchestratorResponse> PostSkillsEditModelAsync(VacancyRouteModel vrm, SkillsEditModel m, VacancyUser user) { var vacancy = await _utility.GetAuthorisedVacancyForEditAsync(vrm, RouteNames.Skills_Post); if (m.Skills == null) { m.Skills = new List <string>(); } var currentSkills = new List <string>(); if (vacancy.Skills != null) { currentSkills.AddRange(vacancy.Skills); } SetVacancyWithEmployerReviewFieldIndicators( currentSkills, FieldIdResolver.ToFieldId(v => v.Skills), vacancy, (v) => { _skillsHelper.SetVacancyFromEditModel(v, m); return(v.Skills); }); // when adding a custom skill the vacancy is not saved immediately, the new custom skill is // validated but all the updates are saved later in a single operation var validateOnly = m.IsAddingCustomSkill; return(await ValidateAndExecute(vacancy, v => { var result = _vacancyClient.Validate(v, ValidationRules); SyncErrorsAndModel(result.Errors, m, vacancy); return result; }, v => validateOnly?Task.CompletedTask : _vacancyClient.UpdateDraftVacancyAsync(v, user))); }
public static ReviewFieldMappingLookupsForPage GetLocationFieldIndicators() { var vms = new List <ReviewFieldIndicatorViewModel> { new ReviewFieldIndicatorViewModel(FieldIdentifiers.EmployerAddress, nameof(LocationEditModel.AddressLine1)), new ReviewFieldIndicatorViewModel(FieldIdentifiers.EmployerAddress1, nameof(LocationEditModel.AddressLine1)), new ReviewFieldIndicatorViewModel(FieldIdentifiers.EmployerAddress2, nameof(LocationEditModel.AddressLine2)), new ReviewFieldIndicatorViewModel(FieldIdentifiers.EmployerAddress3, nameof(LocationEditModel.AddressLine3)), new ReviewFieldIndicatorViewModel(FieldIdentifiers.EmployerAddress4, nameof(LocationEditModel.AddressLine4)) }; var mappings = new Dictionary <string, IEnumerable <string> > { { FieldIdResolver.ToFieldId(v => v.EmployerLocation.AddressLine1), new [] { FieldIdentifiers.EmployerAddress1 } }, { FieldIdResolver.ToFieldId(v => v.EmployerLocation.AddressLine2), new [] { FieldIdentifiers.EmployerAddress2 } }, { FieldIdResolver.ToFieldId(v => v.EmployerLocation.AddressLine3), new [] { FieldIdentifiers.EmployerAddress3 } }, { FieldIdResolver.ToFieldId(v => v.EmployerLocation.AddressLine4), new [] { FieldIdentifiers.EmployerAddress4 } }, { FieldIdResolver.ToFieldId(v => v.EmployerLocation.Postcode), new[] { FieldIdentifiers.EmployerAddress } } }; return(new ReviewFieldMappingLookupsForPage(vms, mappings)); }
public async Task <OrchestratorResponse> PostDatesEditModelAsync(DatesEditModel m, VacancyUser user) { var vacancy = await Utility.GetAuthorisedVacancyForEditAsync( _client, _vacancyClient, m, RouteNames.Dates_Post); SetVacancyWithProviderReviewFieldIndicators( vacancy.ClosingDate, FieldIdResolver.ToFieldId(v => v.ClosingDate), vacancy, (v) => { return(v.ClosingDate = m.ClosingDate.AsDateTimeUk()?.ToUniversalTime()); }); SetVacancyWithProviderReviewFieldIndicators( vacancy.StartDate, FieldIdResolver.ToFieldId(v => v.StartDate), vacancy, (v) => { return(v.StartDate = m.StartDate.AsDateTimeUk()?.ToUniversalTime()); }); SetVacancyWithProviderReviewFieldIndicators( vacancy.DisabilityConfident, FieldIdResolver.ToFieldId(v => v.DisabilityConfident), vacancy, (v) => { return(v.DisabilityConfident = m.IsDisabilityConfident ? DisabilityConfident.Yes : DisabilityConfident.No); }); return(await ValidateAndExecute( vacancy, v => _vacancyClient.Validate(v, ValidationRules), v => _vacancyClient.UpdateDraftVacancyAsync(vacancy, user) )); }
public async Task <OrchestratorResponse <Guid> > PostNumberOfPositionsEditModelAsync(NumberOfPositionsEditModel model, VacancyUser user) { var vacancy = await Utility.GetAuthorisedVacancyForEditAsync(_providerVacancyClient, _recruitVacancyClient, model, RouteNames.NumberOfPositions_Post); SetVacancyWithProviderReviewFieldIndicators( vacancy.NumberOfPositions, FieldIdResolver.ToFieldId(v => v.NumberOfPositions), vacancy, (v) => { return(v.NumberOfPositions = int.TryParse(model.NumberOfPositions, out var n) ? n : default(int?)); }); return(await ValidateAndExecute( vacancy, v => _recruitVacancyClient.Validate(v, ValidationRules), async v => { await _recruitVacancyClient.UpdateDraftVacancyAsync(vacancy, user); return v.Id; } )); }
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); })); }
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.EmployerAddress, Anchors.EmployerAddress), new ReviewFieldIndicatorViewModel(FieldIdentifiers.Provider, Anchors.Provider), new ReviewFieldIndicatorViewModel(FieldIdentifiers.ProviderContact, Anchors.ProviderContact), new ReviewFieldIndicatorViewModel(FieldIdentifiers.Training, Anchors.Training), new ReviewFieldIndicatorViewModel(FieldIdentifiers.ApplicationMethod, Anchors.ApplicationMethod), new ReviewFieldIndicatorViewModel(FieldIdentifiers.ApplicationUrl, Anchors.ApplicationUrl), new ReviewFieldIndicatorViewModel(FieldIdentifiers.ApplicationInstructions, Anchors.ApplicationInstructions), new ReviewFieldIndicatorViewModel(FieldIdentifiers.EmployerName, Anchors.AboutEmployerSection) }; 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 [] { FieldIdentifiers.EmployerName } }, { 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.ProviderContact.Email), new [] { FieldIdentifiers.ProviderContact } }, { FieldIdResolver.ToFieldId(v => v.ProviderContact.Name), new [] { FieldIdentifiers.ProviderContact } }, { FieldIdResolver.ToFieldId(v => v.ProviderContact.Phone), new [] { FieldIdentifiers.ProviderContact } }, { 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)); }