Skip to content

Commit

Permalink
Merge branch 'master' into CON-3849-Add-link-to-settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Najamuddin-Muhammad authored Sep 14, 2021
2 parents 26de9e9 + 1e4ea8d commit 41f273a
Show file tree
Hide file tree
Showing 48 changed files with 4,079 additions and 710 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public async Task MapFromVacancyAsync(DisplayVacancyViewModel vm, Vacancy vacanc

var allQualifications = await _vacancyClient.GetCandidateQualificationsAsync();

vm.Status = vacancy.Status;
vm.ApplicationMethod = vacancy.ApplicationMethod;
vm.ApplicationInstructions = vacancy.ApplicationInstructions;
vm.ApplicationUrl = vacancy.ApplicationUrl;
Expand All @@ -63,6 +64,7 @@ public async Task MapFromVacancyAsync(DisplayVacancyViewModel vm, Vacancy vacanc
vm.OutcomeDescription = vacancy.OutcomeDescription;
vm.PossibleStartDate = vacancy.StartDate?.AsGdsDate();
vm.ProviderName = vacancy.TrainingProvider?.Name;
vm.ProviderReviewFieldIndicators = vacancy.ProviderReviewFieldIndicators;
vm.Qualifications = vacancy.Qualifications.SortQualifications(allQualifications).AsText();
vm.ShortDescription = vacancy.ShortDescription;
vm.Skills = vacancy.Skills ?? Enumerable.Empty<string>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ public async Task<OrchestratorResponse> PostAboutEmployerEditModelAsync(AboutEmp
v => _vacancyClient.Validate(v, ValidationRules),
async v =>
{
vacancy.EmployerDescription = null; // We don't want to save the description until submission.
await _vacancyClient.UpdateDraftVacancyAsync(vacancy, user);
await UpdateEmployerProfileAsync(vacancy, m.EmployerDescription, user);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace Esfa.Recruit.Employer.Web.ViewModels
{
public abstract class DisplayVacancyViewModel
{
public VacancyStatus Status { get; set; }
public string ApplicationInstructions { get; internal set; }
public ApplicationMethod? ApplicationMethod { get; internal set; }
public string ApplicationUrl { get; internal set; }
Expand Down Expand Up @@ -34,6 +35,7 @@ public abstract class DisplayVacancyViewModel
public string OutcomeDescription { get; internal set; }
public string PossibleStartDate { get; internal set; }
public string ProviderName { get; internal set; }
public List<ProviderReviewFieldIndicator> ProviderReviewFieldIndicators { get; internal set; }
public IEnumerable<string> Qualifications { get; internal set; }
public string ShortDescription { get; internal set; }
public IEnumerable<string> Skills { get; internal set; }
Expand Down
788 changes: 503 additions & 285 deletions src/Employer/Employer.Web/Views/VacancyPreview/VacancyPreview.cshtml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public async Task MapFromVacancyAsync(DisplayVacancyViewModel vm, Vacancy vacanc
vm.EmployerName = await _vacancyClient.GetEmployerNameAsync(vacancy);
vm.EmployerWebsiteUrl = vacancy.EmployerWebsiteUrl;
vm.EmployerAddressElements = Enumerable.Empty<string>();
vm.EmployerRejectedReason = vacancy.EmployerRejectedReason;
vm.EmployerReviewFieldIndicators = vacancy.EmployerReviewFieldIndicators;
vm.FindAnApprenticeshipUrl = _externalLinksConfiguration.FindAnApprenticeshipUrl;
vm.IsAnonymous = vacancy.IsAnonymous;
vm.NumberOfPositions = vacancy.NumberOfPositions?.ToString();
Expand Down
35 changes: 29 additions & 6 deletions src/Provider/Provider.Web/Orchestrators/Part1/DatesOrchestrator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
using Esfa.Recruit.Shared.Web.Extensions;
using Esfa.Recruit.Vacancies.Client.Domain.Extensions;
using Microsoft.Extensions.Logging;
using Esfa.Recruit.Vacancies.Client.Application.Services;

namespace Esfa.Recruit.Provider.Web.Orchestrators.Part1
{
public class DatesOrchestrator : EntityValidatingOrchestrator<Vacancy, DatesEditModel>
public class DatesOrchestrator : VacancyValidatingOrchestrator<DatesEditModel>
{
private const VacancyRuleSet ValidationRules = VacancyRuleSet.ClosingDate | VacancyRuleSet.StartDate | VacancyRuleSet.StartDateEndDate | VacancyRuleSet.TrainingExpiryDate;
private readonly IProviderVacancyClient _client;
Expand Down Expand Up @@ -95,11 +96,33 @@ public async Task<OrchestratorResponse> PostDatesEditModelAsync(DatesEditModel m
var vacancy = await Utility.GetAuthorisedVacancyForEditAsync(
_client, _vacancyClient, m, RouteNames.Dates_Post);

vacancy.ClosingDate = m.ClosingDate.AsDateTimeUk()?.ToUniversalTime();
vacancy.StartDate = m.StartDate.AsDateTimeUk()?.ToUniversalTime();

vacancy.DisabilityConfident = m.IsDisabilityConfident ? DisabilityConfident.Yes : DisabilityConfident.No;

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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
using Esfa.Recruit.Vacancies.Client.Infrastructure.Client;
using Microsoft.Extensions.Logging;
using Esfa.Recruit.Shared.Web.Extensions;
using Esfa.Recruit.Vacancies.Client.Application.Services;

namespace Esfa.Recruit.Provider.Web.Orchestrators.Part1
{
public class DurationOrchestrator : EntityValidatingOrchestrator<Vacancy, DurationEditModel>
public class DurationOrchestrator : VacancyValidatingOrchestrator<DurationEditModel>
{
private const VacancyRuleSet ValidationRules = VacancyRuleSet.Duration | VacancyRuleSet.WorkingWeekDescription | VacancyRuleSet.WeeklyHours;
private readonly IProviderVacancyClient _client;
Expand Down Expand Up @@ -75,10 +76,41 @@ public async Task<OrchestratorResponse> PostDurationEditModelAsync(DurationEditM
if(vacancy.Wage == null)
vacancy.Wage = new Wage();

vacancy.Wage.Duration = int.TryParse(m.Duration, out int duration) ? duration : default(int?);
vacancy.Wage.DurationUnit = m.DurationUnit;
vacancy.Wage.WorkingWeekDescription = m.WorkingWeekDescription;
vacancy.Wage.WeeklyHours = m.WeeklyHours.AsDecimal(2);
SetVacancyWithProviderReviewFieldIndicators(
vacancy.Wage.Duration,
FieldIdResolver.ToFieldId(v => v.Wage.Duration),
vacancy,
(v) =>
{
return v.Wage.Duration = int.TryParse(m.Duration, out int duration) ? duration : default(int?);
});

SetVacancyWithProviderReviewFieldIndicators(
vacancy.Wage.DurationUnit,
FieldIdResolver.ToFieldId(v => v.Wage.DurationUnit),
vacancy,
(v) =>
{
return v.Wage.DurationUnit = m.DurationUnit;
});

SetVacancyWithProviderReviewFieldIndicators(
vacancy.Wage.WorkingWeekDescription,
FieldIdResolver.ToFieldId(v => v.Wage.WorkingWeekDescription),
vacancy,
(v) =>
{
return v.Wage.WorkingWeekDescription = m.WorkingWeekDescription;
});

SetVacancyWithProviderReviewFieldIndicators(
vacancy.Wage.WeeklyHours,
FieldIdResolver.ToFieldId(v => v.Wage.WeeklyHours),
vacancy,
(v) =>
{
return v.Wage.WeeklyHours = m.WeeklyHours.AsDecimal(2);
});

return await ValidateAndExecute(
vacancy,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
using Esfa.Recruit.Provider.Web.Models;
using Esfa.Recruit.Shared.Web.Models;
using Address = Esfa.Recruit.Vacancies.Client.Domain.Entities.Address;
using Esfa.Recruit.Vacancies.Client.Application.Services;

namespace Esfa.Recruit.Provider.Web.Orchestrators.Part1
{
public class LocationOrchestrator : EntityValidatingOrchestrator<Vacancy, LocationEditModel>
public class LocationOrchestrator : VacancyValidatingOrchestrator<LocationEditModel>
{
private const VacancyRuleSet ValidationRules = VacancyRuleSet.EmployerAddress;
private readonly IProviderVacancyClient _providerVacancyClient;
Expand Down Expand Up @@ -130,14 +131,91 @@ public async Task<OrchestratorResponse> PostLocationEditModelAsync(

var matchingAddress = GetMatchingAddress(newLocation, allLocations);

vacancy.EmployerLocation = matchingAddress ?? ConvertToDomainAddress(locationEditModel);
var employerLocation = matchingAddress != null ? matchingAddress : ConvertToDomainAddress(locationEditModel);

//if cookie is found update legal entity and name option
// this has diverged from the usual pattern because the individual properties are review fields
SetVacancyWithProviderReviewFieldIndicators(
vacancy.EmployerLocation?.AddressLine1,
FieldIdResolver.ToFieldId(v => v.EmployerLocation.AddressLine1),
vacancy,
(v) =>
{
return employerLocation.AddressLine1;
});

SetVacancyWithProviderReviewFieldIndicators(
vacancy.EmployerLocation?.AddressLine2,
FieldIdResolver.ToFieldId(v => v.EmployerLocation.AddressLine2),
vacancy,
(v) =>
{
return employerLocation.AddressLine2;
});

SetVacancyWithProviderReviewFieldIndicators(
vacancy.EmployerLocation?.AddressLine3,
FieldIdResolver.ToFieldId(v => v.EmployerLocation.AddressLine3),
vacancy,
(v) =>
{
return employerLocation.AddressLine3;
});

SetVacancyWithProviderReviewFieldIndicators(
vacancy.EmployerLocation?.AddressLine4,
FieldIdResolver.ToFieldId(v => v.EmployerLocation.AddressLine4),
vacancy,
(v) =>
{
return employerLocation.AddressLine4;
});

SetVacancyWithProviderReviewFieldIndicators(
vacancy.EmployerLocation?.Postcode,
FieldIdResolver.ToFieldId(v => v.EmployerLocation.Postcode),
vacancy,
(v) =>
{
return employerLocation.Postcode;
});

vacancy.EmployerLocation = employerLocation;

// if cookie is found update legal entity and name option
if (employerInfoModel != null)
{
vacancy.LegalEntityName = selectedOrganisation.Name;
SetVacancyWithProviderReviewFieldIndicators(
vacancy.LegalEntityName,
FieldIdResolver.ToFieldId(v => v.EmployerName),
vacancy,
(v) =>
{
return v.LegalEntityName = selectedOrganisation.Name;
});

SetVacancyWithProviderReviewFieldIndicators(
vacancy.EmployerNameOption,
FieldIdResolver.ToFieldId(v => v.EmployerName),
vacancy,
(v) =>
{
return v.EmployerNameOption = employerInfoModel.EmployerIdentityOption?.ConvertToDomainOption();
});

if (employerInfoModel.EmployerIdentityOption == EmployerIdentityOption.NewTradingName)
{
SetVacancyWithProviderReviewFieldIndicators(
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.EmployerNameOption = employerInfoModel.EmployerIdentityOption?.ConvertToDomainOption();
vacancy.AnonymousReason = vacancy.IsAnonymous ? employerInfoModel.AnonymousReason : null;
vacancy.EmployerName = vacancy.IsAnonymous ? employerInfoModel.AnonymousName : null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
using Esfa.Recruit.Provider.Web.ViewModels.Part1.NumberOfPositions;
using Esfa.Recruit.Shared.Web.Orchestrators;
using Esfa.Recruit.Shared.Web.Services;
using Esfa.Recruit.Vacancies.Client.Application.Services;
using Esfa.Recruit.Vacancies.Client.Application.Validation;
using Esfa.Recruit.Vacancies.Client.Domain.Entities;
using Esfa.Recruit.Vacancies.Client.Infrastructure.Client;
using Microsoft.Extensions.Logging;

namespace Esfa.Recruit.Provider.Web.Orchestrators.Part1
{
public class NumberOfPositionsOrchestrator : EntityValidatingOrchestrator<Vacancy, NumberOfPositionsEditModel>
public class NumberOfPositionsOrchestrator : VacancyValidatingOrchestrator<NumberOfPositionsEditModel>
{
private const VacancyRuleSet ValidationRules = VacancyRuleSet.NumberOfPositions;
private readonly IProviderVacancyClient _providerVacancyClient;
Expand Down Expand Up @@ -58,9 +59,17 @@ public async Task<NumberOfPositionsViewModel> GetNumberOfPositionsViewModelFromE

public async Task<OrchestratorResponse<Guid>> PostNumberOfPositionsEditModelAsync(NumberOfPositionsEditModel model, VacancyUser user)
{
var numberOfPositions = int.TryParse(model.NumberOfPositions, out var n) ? n : default(int?);
var vacancy = await Utility.GetAuthorisedVacancyForEditAsync(_providerVacancyClient, _recruitVacancyClient, model, RouteNames.NumberOfPositions_Post);
vacancy.NumberOfPositions = numberOfPositions;

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),
Expand Down
12 changes: 10 additions & 2 deletions src/Provider/Provider.Web/Orchestrators/Part1/TitleOrchestrator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Esfa.Recruit.Shared.Web.Services;
using Esfa.Recruit.Shared.Web.ViewModels;
using Esfa.Recruit.Vacancies.Client.Application.Exceptions;
using Esfa.Recruit.Vacancies.Client.Application.Services;
using Esfa.Recruit.Vacancies.Client.Application.Validation;
using Esfa.Recruit.Vacancies.Client.Domain.Entities;
using Esfa.Recruit.Vacancies.Client.Domain.Exceptions;
Expand All @@ -17,7 +18,7 @@

namespace Esfa.Recruit.Provider.Web.Orchestrators.Part1
{
public class TitleOrchestrator : EntityValidatingOrchestrator<Vacancy, TitleEditModel>
public class TitleOrchestrator : VacancyValidatingOrchestrator<TitleEditModel>
{
private const VacancyRuleSet ValidationRules = VacancyRuleSet.Title;
private readonly IProviderVacancyClient _providerVacancyClient;
Expand Down Expand Up @@ -94,7 +95,14 @@ public async Task<OrchestratorResponse<Guid>> PostTitleEditModelAsync(VacancyRou
{
var vacancy = await Utility.GetAuthorisedVacancyForEditAsync(_providerVacancyClient, _recruitVacancyClient, vrm, RouteNames.Title_Post);

vacancy.Title = model.Title;
SetVacancyWithProviderReviewFieldIndicators(
vacancy.Title,
FieldIdResolver.ToFieldId(v => v.Title),
vacancy,
(v) =>
{
return v.Title = model.Title;
});

return await ValidateAndExecute(
vacancy,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
using Microsoft.Extensions.Logging;
using Esfa.Recruit.Vacancies.Client.Domain.Extensions;
using Esfa.Recruit.Shared.Web.Helpers;
using Esfa.Recruit.Vacancies.Client.Application.Services;

namespace Esfa.Recruit.Provider.Web.Orchestrators.Part1
{
public class TrainingOrchestrator : EntityValidatingOrchestrator<Vacancy, TrainingEditModel>
public class TrainingOrchestrator : VacancyValidatingOrchestrator<TrainingEditModel>
{
private const VacancyRuleSet ValidationRules = VacancyRuleSet.TrainingProgramme;
private readonly IProviderVacancyClient _client;
Expand Down Expand Up @@ -97,7 +98,14 @@ public async Task<OrchestratorResponse> PostConfirmTrainingEditModelAsync(Confir
{
var vacancy = await Utility.GetAuthorisedVacancyForEditAsync(_client, _vacancyClient, m, RouteNames.Training_Confirm_Post);

vacancy.ProgrammeId = m.ProgrammeId;
SetVacancyWithProviderReviewFieldIndicators(
vacancy.ProgrammeId,
FieldIdResolver.ToFieldId(v => v.ProgrammeId),
vacancy,
(v) =>
{
return v.ProgrammeId = m.ProgrammeId;
});

return await ValidateAndExecute(
vacancy,
Expand Down
Loading

0 comments on commit 41f273a

Please sign in to comment.