Skip to content

Commit

Permalink
Merge pull request #987 from SkillsFundingAgency/CON-3791_Provider_re…
Browse files Browse the repository at this point in the history
…submit_after_employer_reject

CON-3791 Provider resubmit after employer reject
  • Loading branch information
Najamuddin-Muhammad authored Sep 7, 2021
2 parents c49d9de + d347d38 commit 25f6b0b
Show file tree
Hide file tree
Showing 41 changed files with 3,561 additions and 423 deletions.
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
36 changes: 30 additions & 6 deletions src/Provider/Provider.Web/Orchestrators/Part1/WageOrchestrator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
using Esfa.Recruit.Vacancies.Client.Domain.Extensions;
using SFA.DAS.VacancyServices.Wage;
using WageType = Esfa.Recruit.Vacancies.Client.Domain.Entities.WageType;
using Esfa.Recruit.Vacancies.Client.Application.Services;

namespace Esfa.Recruit.Provider.Web.Orchestrators.Part1
{
public class WageOrchestrator : EntityValidatingOrchestrator<Vacancy, WageEditModel>
public class WageOrchestrator : VacancyValidatingOrchestrator<WageEditModel>
{
private const VacancyRuleSet ValidationRules = VacancyRuleSet.Wage | VacancyRuleSet.MinimumWage;
private readonly IProviderVacancyClient _client;
Expand Down Expand Up @@ -84,11 +85,34 @@ public async Task<OrchestratorResponse> PostWageEditModelAsync(WageEditModel m,

if(vacancy.Wage == null)
vacancy.Wage = new Wage();

vacancy.Wage.WageType = m.WageType;
vacancy.Wage.FixedWageYearlyAmount = (m.WageType == WageType.FixedWage) ? m.FixedWageYearlyAmount?.AsMoney() : null;
vacancy.Wage.WageAdditionalInformation = m.WageAdditionalInformation;


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),
Expand Down
Loading

0 comments on commit 25f6b0b

Please sign in to comment.