From 53805639871b32a5a109004b5c13eaf747a4dd9c Mon Sep 17 00:00:00 2001 From: Shoma Gujjar Date: Thu, 30 Jul 2020 16:38:51 +0100 Subject: [PATCH 01/12] CON-1186-use-account-legal-public-hashedid --- .../Part1/LocationOrchestrator.cs | 2 +- .../Part1/LocationOrchestrator.cs | 2 +- .../RefreshEmployerProfilesCommandHandler.cs | 18 ++++++++++++------ .../UpdateEmployerProfileCommandHandler.cs | 6 ++++-- .../Commands/RefreshEmployerProfilesCommand.cs | 1 - .../Domain/Entities/EmployerProfile.cs | 5 +++++ .../Client/IEmployerVacancyClient.cs | 1 - .../MongoDbEmployerProfileRepository.cs | 3 ++- 8 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/Employer/Employer.Web/Orchestrators/Part1/LocationOrchestrator.cs b/src/Employer/Employer.Web/Orchestrators/Part1/LocationOrchestrator.cs index daf150a155..5e0f5b785a 100644 --- a/src/Employer/Employer.Web/Orchestrators/Part1/LocationOrchestrator.cs +++ b/src/Employer/Employer.Web/Orchestrators/Part1/LocationOrchestrator.cs @@ -202,7 +202,7 @@ private async Task UpdateEmployerProfile(VacancyEmployerInfoModel employerInfoMo private async Task> GetAllAvailableLocationsAsync(EmployerProfile employerProfile) { var employerData = await _employerVacancyClient.GetEditVacancyInfoAsync(employerProfile.EmployerAccountId); - var legalEntity = employerData.LegalEntities.First(l => l.LegalEntityId == employerProfile.LegalEntityId); + var legalEntity = employerData.LegalEntities.First(l => l.AccountLegalEntityPublicHashedId == employerProfile.AccountLegalEntityPublicHashedId); var locations = new List
(); locations.Add(legalEntity.Address.ConvertToDomainAddress()); diff --git a/src/Provider/Provider.Web/Orchestrators/Part1/LocationOrchestrator.cs b/src/Provider/Provider.Web/Orchestrators/Part1/LocationOrchestrator.cs index 59e2ea79b1..3028d45b1f 100644 --- a/src/Provider/Provider.Web/Orchestrators/Part1/LocationOrchestrator.cs +++ b/src/Provider/Provider.Web/Orchestrators/Part1/LocationOrchestrator.cs @@ -193,7 +193,7 @@ private async Task> GetAllAvailableLocationsAsync(EmployerProfile { var providerData = await _providerVacancyClient.GetProviderEditVacancyInfoAsync(ukprn); var employerInfo = providerData.Employers.Single(e => e.EmployerAccountId == vacancy.EmployerAccountId); - var legalEntity = employerInfo.LegalEntities.First(l => l.LegalEntityId == employerProfile.LegalEntityId); + var legalEntity = employerInfo.LegalEntities.First(l => l.AccountLegalEntityPublicHashedId == employerProfile.AccountLegalEntityPublicHashedId); var locations = new List
(); locations.Add(legalEntity.Address.ConvertToDomainAddress()); locations.AddRange(employerProfile.OtherLocations); diff --git a/src/Shared/Recruit.Vacancies.Client/Application/CommandHandlers/RefreshEmployerProfilesCommandHandler.cs b/src/Shared/Recruit.Vacancies.Client/Application/CommandHandlers/RefreshEmployerProfilesCommandHandler.cs index 50b6f91467..45b68a6e38 100644 --- a/src/Shared/Recruit.Vacancies.Client/Application/CommandHandlers/RefreshEmployerProfilesCommandHandler.cs +++ b/src/Shared/Recruit.Vacancies.Client/Application/CommandHandlers/RefreshEmployerProfilesCommandHandler.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -7,6 +6,7 @@ using Esfa.Recruit.Vacancies.Client.Application.Providers; using Esfa.Recruit.Vacancies.Client.Domain.Entities; using Esfa.Recruit.Vacancies.Client.Domain.Repositories; +using Esfa.Recruit.Vacancies.Client.Infrastructure.Client; using MediatR; using Microsoft.Extensions.Logging; @@ -17,28 +17,33 @@ public class RefreshEmployerProfilesCommandHandler : IRequestHandler _logger; private readonly IEmployerProfileRepository _employerProfileRepository; private readonly ITimeProvider _time; + private readonly IEmployerVacancyClient _employerVacancyClient; public RefreshEmployerProfilesCommandHandler( ILogger logger, IEmployerProfileRepository employerProfileRepository, - ITimeProvider time) + ITimeProvider time, IEmployerVacancyClient employerVacancyClient) { _logger = logger; _employerProfileRepository = employerProfileRepository; _time = time; + _employerVacancyClient = employerVacancyClient; } public async Task Handle(RefreshEmployerProfilesCommand message, CancellationToken cancellationToken) { _logger.LogInformation("Refreshing Employer Profiles for {employerAccountId}", message.EmployerAccountId); - + var employerVacancyInfoTask = + _employerVacancyClient.GetEditVacancyInfoAsync(message.EmployerAccountId); var tasks = new List(); - + var editVacancyInfo = employerVacancyInfoTask.Result; // Get all current profiles for the employer var profiles = await _employerProfileRepository.GetEmployerProfilesForEmployerAsync(message.EmployerAccountId); foreach (var legalEntity in message.LegalEntityIds) { + var selectedOrganisation = + editVacancyInfo.LegalEntities.Single(l => l.LegalEntityId == legalEntity); if (!profiles.Any(x => x.LegalEntityId == legalEntity)) { var currentTime = _time.Now; @@ -48,7 +53,8 @@ public async Task Handle(RefreshEmployerProfilesCommand message, CancellationTok { EmployerAccountId = message.EmployerAccountId, LegalEntityId = legalEntity, - CreatedDate = currentTime + CreatedDate = currentTime, + AccountLegalEntityPublicHashedId = selectedOrganisation.AccountLegalEntityPublicHashedId }; _logger.LogInformation("Adding new profile for employer account: {employerAccountId} and legal entity id: {legalEntityId}", message.EmployerAccountId, legalEntity); diff --git a/src/Shared/Recruit.Vacancies.Client/Application/CommandHandlers/UpdateEmployerProfileCommandHandler.cs b/src/Shared/Recruit.Vacancies.Client/Application/CommandHandlers/UpdateEmployerProfileCommandHandler.cs index 06a095786e..c1f0d3a748 100644 --- a/src/Shared/Recruit.Vacancies.Client/Application/CommandHandlers/UpdateEmployerProfileCommandHandler.cs +++ b/src/Shared/Recruit.Vacancies.Client/Application/CommandHandlers/UpdateEmployerProfileCommandHandler.cs @@ -28,10 +28,12 @@ public async Task Handle(UpdateEmployerProfileCommand message, CancellationToken { message.Profile.LastUpdatedDate = _time.Now; message.Profile.LastUpdatedBy = message.User; - + await _employerProfileRepository.UpdateAsync(message.Profile); - _logger.LogInformation("Update Employer profile for employer account: {employerAccountId} and legal entity: {legalEntityId} ", message.Profile.EmployerAccountId, message.Profile.LegalEntityId); + _logger.LogInformation("Update Employer profile for employer account: {employerAccountId} and " + + "legal entity: {legalEntityId} AccountLegalEntityPublicHashedId:{AccountLegalEntityPublicHashedId}", message.Profile.EmployerAccountId, + message.Profile.LegalEntityId, message.Profile.AccountLegalEntityPublicHashedId); } } } \ No newline at end of file diff --git a/src/Shared/Recruit.Vacancies.Client/Application/Commands/RefreshEmployerProfilesCommand.cs b/src/Shared/Recruit.Vacancies.Client/Application/Commands/RefreshEmployerProfilesCommand.cs index 60e034ef67..9176a45287 100644 --- a/src/Shared/Recruit.Vacancies.Client/Application/Commands/RefreshEmployerProfilesCommand.cs +++ b/src/Shared/Recruit.Vacancies.Client/Application/Commands/RefreshEmployerProfilesCommand.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using Esfa.Recruit.Vacancies.Client.Domain.Entities; using Esfa.Recruit.Vacancies.Client.Domain.Messaging; using MediatR; diff --git a/src/Shared/Recruit.Vacancies.Client/Domain/Entities/EmployerProfile.cs b/src/Shared/Recruit.Vacancies.Client/Domain/Entities/EmployerProfile.cs index 301bd8aefc..9eff6058be 100644 --- a/src/Shared/Recruit.Vacancies.Client/Domain/Entities/EmployerProfile.cs +++ b/src/Shared/Recruit.Vacancies.Client/Domain/Entities/EmployerProfile.cs @@ -19,6 +19,11 @@ public static string GetId(string employerAccountId, long legalEntityId) { return string.Format(IdFormat, employerAccountId, legalEntityId); } + public static string GetId(string employerAccountId, string accountLegalEntityPublicHashedId) + { + return string.Format(IdFormat, employerAccountId, accountLegalEntityPublicHashedId); + } public IList
OtherLocations { get; set; } = new List
(); + public string AccountLegalEntityPublicHashedId { get; set; } } } diff --git a/src/Shared/Recruit.Vacancies.Client/Infrastructure/Client/IEmployerVacancyClient.cs b/src/Shared/Recruit.Vacancies.Client/Infrastructure/Client/IEmployerVacancyClient.cs index 3c780daba7..72f1d2a5d0 100644 --- a/src/Shared/Recruit.Vacancies.Client/Infrastructure/Client/IEmployerVacancyClient.cs +++ b/src/Shared/Recruit.Vacancies.Client/Infrastructure/Client/IEmployerVacancyClient.cs @@ -4,7 +4,6 @@ using Esfa.Recruit.Vacancies.Client.Domain.Entities; using Esfa.Recruit.Vacancies.Client.Infrastructure.QueryStore.Projections.Employer; using Esfa.Recruit.Vacancies.Client.Infrastructure.QueryStore.Projections.EditVacancyInfo; -using Esfa.Recruit.Vacancies.Client.Infrastructure.Services.TrainingProvider; using Esfa.Recruit.Vacancies.Client.Application.Validation; namespace Esfa.Recruit.Vacancies.Client.Infrastructure.Client diff --git a/src/Shared/Recruit.Vacancies.Client/Infrastructure/Repositories/MongoDbEmployerProfileRepository.cs b/src/Shared/Recruit.Vacancies.Client/Infrastructure/Repositories/MongoDbEmployerProfileRepository.cs index 9d908259c2..1797c03654 100644 --- a/src/Shared/Recruit.Vacancies.Client/Infrastructure/Repositories/MongoDbEmployerProfileRepository.cs +++ b/src/Shared/Recruit.Vacancies.Client/Infrastructure/Repositories/MongoDbEmployerProfileRepository.cs @@ -56,7 +56,8 @@ public Task UpdateAsync(EmployerProfile profile) { var builder = Builders.Filter; var filter = builder.Eq(x => x.EmployerAccountId, profile.EmployerAccountId) & - builder.Eq(x => x.LegalEntityId, profile.LegalEntityId); + builder.Eq(x => x.LegalEntityId, profile.LegalEntityId) & + builder.Eq(x => x.AccountLegalEntityPublicHashedId, profile.AccountLegalEntityPublicHashedId); var collection = GetCollection(); From e4f4d7873fa245635906e58fe8bc6704e4259179 Mon Sep 17 00:00:00 2001 From: Shoma Gujjar Date: Fri, 31 Jul 2020 14:00:53 +0100 Subject: [PATCH 02/12] CON-1186-remove legal entity id --- .../LegalEntityAgreementController.cs | 2 +- .../Controllers/Part1/EmployerController.cs | 14 ++++---- .../Models/VacancyEmployerInfoModel.cs | 3 +- .../LegalEntityAgreementOrchestrator.cs | 8 ++--- .../Part1/EmployerNameOrchestrator.cs | 6 ++-- .../Part1/EmployerOrchestrator.cs | 32 ++++++++--------- .../Part1/LocationOrchestrator.cs | 18 ++++++---- .../Part2/AboutEmployerOrchestrator.cs | 2 +- .../VacancyPreviewOrchestrator.cs | 2 +- .../Part1/Employer/EmployerEditModel.cs | 4 +-- .../Part1/Employer/EmployerViewModel.cs | 14 ++++---- .../Handlers/Employer/SetupEmployerHandler.cs | 2 +- .../Part1/LegalEntityController.cs | 12 +++---- .../Models/VacancyEmployerInfoModel.cs | 2 +- .../LegalEntityAgreementOrchestrator.cs | 2 +- .../Part1/EmployerNameOrchestrator.cs | 6 ++-- .../Part1/LegalEntityOrchestrator.cs | 22 ++++++------ .../Part1/LocationOrchestrator.cs | 25 +++++++------- .../VacancyPreviewOrchestrator.cs | 2 +- .../Part1/LegalEntity/LegalEntityEditModel.cs | 2 +- .../Part1/LegalEntity/LegalEntityViewModel.cs | 10 +++--- .../Part1/LegalEntityOrchestratorTests.cs | 4 +-- .../VacancyPreviewOrchestratorTests.cs | 5 +-- .../Services/ILegalEntityAgreementService.cs | 4 +-- .../Services/LegalEntityAgreementService.cs | 8 ++--- .../RefreshEmployerProfilesCommandHandler.cs | 11 +++--- .../UpdateEmployerProfileCommandHandler.cs | 4 +-- .../RefreshEmployerProfilesCommand.cs | 2 +- .../Application/Services/EmployerService.cs | 4 +-- .../Domain/Entities/EmployerProfile.cs | 10 ++---- .../IEmployerProfileRepository.cs | 2 +- .../Client/IJobsVacancyClient.cs | 2 +- .../Client/IRecruitVacancyClient.cs | 2 +- .../Infrastructure/Client/VacancyClient.cs | 8 ++--- .../MongoDbEmployerProfileRepository.cs | 5 ++- .../LegalEntityAgreementServiceTests.cs | 34 +++++++++++-------- .../GetEmployerDescriptionTests.cs | 4 +-- .../EmployerService/GetEmployerNameTests.cs | 2 +- 38 files changed, 150 insertions(+), 151 deletions(-) diff --git a/src/Employer/Employer.Web/Controllers/LegalEntityAgreementController.cs b/src/Employer/Employer.Web/Controllers/LegalEntityAgreementController.cs index 32d228a64a..2f848cc3be 100644 --- a/src/Employer/Employer.Web/Controllers/LegalEntityAgreementController.cs +++ b/src/Employer/Employer.Web/Controllers/LegalEntityAgreementController.cs @@ -24,7 +24,7 @@ public LegalEntityAgreementController( public async Task LegalEntityAgreementSoftStop(VacancyRouteModel vrm, [FromQuery] string wizard = "true") { var info = GetVacancyEmployerInfoCookie(vrm.VacancyId); - var vm = await _orchestrator.GetLegalEntityAgreementSoftStopViewModelAsync(vrm, info.LegalEntityId); + var vm = await _orchestrator.GetLegalEntityAgreementSoftStopViewModelAsync(vrm, info.AccountLegalEntityPublicHashedId); vm.PageInfo.SetWizard(wizard); if (vm.HasLegalEntityAgreement == false) diff --git a/src/Employer/Employer.Web/Controllers/Part1/EmployerController.cs b/src/Employer/Employer.Web/Controllers/Part1/EmployerController.cs index 80f925eb7a..b2822d51ae 100644 --- a/src/Employer/Employer.Web/Controllers/Part1/EmployerController.cs +++ b/src/Employer/Employer.Web/Controllers/Part1/EmployerController.cs @@ -25,15 +25,15 @@ public async Task Employer(VacancyRouteModel vrm, [FromQuery]stri { var info = GetVacancyEmployerInfoCookie(vrm.VacancyId); - var vm = await _orchestrator.GetEmployerViewModelAsync(vrm, searchTerm, page, info?.LegalEntityId); + var vm = await _orchestrator.GetEmployerViewModelAsync(vrm, searchTerm, page, info?.AccountLegalEntityPublicHashedId); - if (info == null || !info.LegalEntityId.HasValue) + if (info == null || !string.IsNullOrEmpty(info.AccountLegalEntityPublicHashedId)) { SetVacancyEmployerInfoCookie(vm.VacancyEmployerInfoModel); } else { - vm.SelectedOrganisationId = info.LegalEntityId; + vm.AccountLegalEntityPublicHashedId = info.AccountLegalEntityPublicHashedId; } if (vm.HasOnlyOneOrganisation) @@ -54,22 +54,22 @@ public async Task Employer(EmployerEditModel m, [FromQuery] bool { //something went wrong, the matching cookie was not found //Redirect the user with validation error to allow them to continue - ModelState.AddModelError(nameof(EmployerEditModel.SelectedOrganisationId), + ModelState.AddModelError(nameof(EmployerEditModel.AccountLegalEntityPublicHashedId), ValidationMessages.EmployerSelectionValidationMessages.EmployerSelectionRequired); } if (!ModelState.IsValid) { - var vm = await _orchestrator.GetEmployerViewModelAsync(m, m.SearchTerm, m.Page, info?.LegalEntityId); + var vm = await _orchestrator.GetEmployerViewModelAsync(m, m.SearchTerm, m.Page, info?.AccountLegalEntityPublicHashedId); SetVacancyEmployerInfoCookie(vm.VacancyEmployerInfoModel); vm.Pager.OtherRouteValues.Add(nameof(wizard), wizard.ToString()); vm.PageInfo.SetWizard(wizard); return View(vm); } - if (info.LegalEntityId != m.SelectedOrganisationId) + if (info.AccountLegalEntityPublicHashedId != m.AccountLegalEntityPublicHashedId) { - info.LegalEntityId = m.SelectedOrganisationId; + info.AccountLegalEntityPublicHashedId = m.AccountLegalEntityPublicHashedId; info.HasLegalEntityChanged = true; info.EmployerIdentityOption = null; info.NewTradingName = null; diff --git a/src/Employer/Employer.Web/Models/VacancyEmployerInfoModel.cs b/src/Employer/Employer.Web/Models/VacancyEmployerInfoModel.cs index 0d1491faad..e7f05ba70e 100644 --- a/src/Employer/Employer.Web/Models/VacancyEmployerInfoModel.cs +++ b/src/Employer/Employer.Web/Models/VacancyEmployerInfoModel.cs @@ -1,5 +1,4 @@ using System; -using Esfa.Recruit.Employer.Web.ViewModels.Part1.EmployerName; using Esfa.Recruit.Shared.Web.Models; namespace Esfa.Recruit.Employer.Web.Models @@ -7,11 +6,11 @@ namespace Esfa.Recruit.Employer.Web.Models public class VacancyEmployerInfoModel { public Guid? VacancyId { get; set; } - public long? LegalEntityId { get; set; } public EmployerIdentityOption? EmployerIdentityOption { get; set; } public string NewTradingName { get; set; } public bool HasLegalEntityChanged { get; set;} public string AnonymousName { get; set; } public string AnonymousReason { get; set; } + public string AccountLegalEntityPublicHashedId { get; set; } } } \ No newline at end of file diff --git a/src/Employer/Employer.Web/Orchestrators/LegalEntityAgreementOrchestrator.cs b/src/Employer/Employer.Web/Orchestrators/LegalEntityAgreementOrchestrator.cs index 167a61d520..5a423987df 100644 --- a/src/Employer/Employer.Web/Orchestrators/LegalEntityAgreementOrchestrator.cs +++ b/src/Employer/Employer.Web/Orchestrators/LegalEntityAgreementOrchestrator.cs @@ -25,16 +25,16 @@ public LegalEntityAgreementOrchestrator( } public async Task GetLegalEntityAgreementSoftStopViewModelAsync( - VacancyRouteModel vrm, long? selectedLegalEntityId) + VacancyRouteModel vrm, string selectedAccountLegalEntityPublicHashedId) { var vacancy = await Utility.GetAuthorisedVacancyForEditAsync( _client, _vacancyClient, vrm, RouteNames.LegalEntityAgreement_SoftStop_Get); - var legalEntityId = selectedLegalEntityId.HasValue ? selectedLegalEntityId.Value : vacancy.LegalEntityId; + var accountLegalEntityPublicHashedId = string.IsNullOrEmpty(selectedAccountLegalEntityPublicHashedId) ? selectedAccountLegalEntityPublicHashedId : vacancy.AccountLegalEntityPublicHashedId; LegalEntity legalEntity = await - _legalEntityAgreementService.GetLegalEntityAsync(vrm.EmployerAccountId, legalEntityId); + _legalEntityAgreementService.GetLegalEntityAsync(vrm.EmployerAccountId, accountLegalEntityPublicHashedId); var hasLegalEntityAgreement = await _legalEntityAgreementService.HasLegalEntityAgreementAsync( @@ -56,7 +56,7 @@ public async Task GetLegalEntityAgreement return new LegalEntityAgreementHardStopViewModel { HasLegalEntityAgreement = await _legalEntityAgreementService.HasLegalEntityAgreementAsync( - vacancy.EmployerAccountId, vacancy.LegalEntityId) + vacancy.EmployerAccountId, vacancy.AccountLegalEntityPublicHashedId) }; } } diff --git a/src/Employer/Employer.Web/Orchestrators/Part1/EmployerNameOrchestrator.cs b/src/Employer/Employer.Web/Orchestrators/Part1/EmployerNameOrchestrator.cs index 860a7895a5..19915a7e92 100644 --- a/src/Employer/Employer.Web/Orchestrators/Part1/EmployerNameOrchestrator.cs +++ b/src/Employer/Employer.Web/Orchestrators/Part1/EmployerNameOrchestrator.cs @@ -42,15 +42,15 @@ public async Task GetEmployerNameViewModelAsync( var vacancy = await Utility.GetAuthorisedVacancyForEditAsync( _employerVacancyClient, _recruitVacancyClient, vrm, RouteNames.Employer_Get); - var legalEntityId = employerInfoModel.LegalEntityId.GetValueOrDefault(); + var accountLegalEntityPublicHashedId = employerInfoModel.AccountLegalEntityPublicHashedId; var getEmployerDataTask = _employerVacancyClient.GetEditVacancyInfoAsync(vrm.EmployerAccountId); - var getEmployerProfileTask = _recruitVacancyClient.GetEmployerProfileAsync(vrm.EmployerAccountId, legalEntityId); + 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.LegalEntityId == legalEntityId); + var legalEntity = editVacancyInfo.LegalEntities.Single(l => l.AccountLegalEntityPublicHashedId == accountLegalEntityPublicHashedId); var vm = new EmployerNameViewModel { diff --git a/src/Employer/Employer.Web/Orchestrators/Part1/EmployerOrchestrator.cs b/src/Employer/Employer.Web/Orchestrators/Part1/EmployerOrchestrator.cs index 4c60ac7b83..191d546a1d 100644 --- a/src/Employer/Employer.Web/Orchestrators/Part1/EmployerOrchestrator.cs +++ b/src/Employer/Employer.Web/Orchestrators/Part1/EmployerOrchestrator.cs @@ -33,7 +33,7 @@ public EmployerOrchestrator( _logger = logger; } - public async Task GetEmployerViewModelAsync(VacancyRouteModel vrm, string searchTerm, int? requestedPageNo, long? selectedLegalEntityId = 0) + public async Task GetEmployerViewModelAsync(VacancyRouteModel vrm, string searchTerm, int? requestedPageNo, string accountLegalEntityPublicHashedId) { const int NotFoundIndex = -1; var setPage = requestedPageNo.HasValue ? requestedPageNo.Value : 1; @@ -49,17 +49,17 @@ public async Task GetEmployerViewModelAsync(VacancyRouteModel var vm = new EmployerViewModel { TotalNumberOfLegalEntities = legalEntities.Count(), - SelectedOrganisationId = vacancy.LegalEntityId, PageInfo = Utility.GetPartOnePageInfo(vacancy), - SearchTerm = searchTerm + SearchTerm = searchTerm, + AccountLegalEntityPublicHashedId = vacancy.AccountLegalEntityPublicHashedId }; - if (vacancy.LegalEntityId != 0 && (selectedLegalEntityId.HasValue == false || selectedLegalEntityId == 0)) - { - selectedLegalEntityId = vacancy.LegalEntityId; - } + //if (vacancy.LegalEntityId != 0 && (selectedLegalEntityId.HasValue == false || selectedLegalEntityId == 0)) + //{ + // selectedLegalEntityId = vacancy.LegalEntityId; + //} - vm.IsPreviouslySelectedLegalEntityStillValid = selectedLegalEntityId.HasValue && legalEntities.Any(le => le.Id == selectedLegalEntityId); + vm.IsPreviouslySelectedLegalEntityStillValid = !string.IsNullOrEmpty(accountLegalEntityPublicHashedId) && legalEntities.Any(le => le.Id == accountLegalEntityPublicHashedId); var filteredLegalEntities = legalEntities .Where(le => string.IsNullOrEmpty(searchTerm) || le.Name.Contains(searchTerm, StringComparison.OrdinalIgnoreCase)) @@ -69,8 +69,8 @@ public async Task GetEmployerViewModelAsync(VacancyRouteModel var filteredLegalEntitiesTotal = filteredLegalEntities.Count(); var totalNumberOfPages = PagingHelper.GetTotalNoOfPages(MaxLegalEntitiesPerPage, filteredLegalEntitiesTotal); - var indexOfSelectedLegalEntity = selectedLegalEntityId.HasValue - ? filteredLegalEntities.FindIndex(le => le.Id == selectedLegalEntityId.Value) + 1 + var indexOfSelectedLegalEntity = !string.IsNullOrEmpty(accountLegalEntityPublicHashedId) + ? filteredLegalEntities.FindIndex(le => le.Id == accountLegalEntityPublicHashedId) + 1 : NotFoundIndex; setPage = GetPageNo(requestedPageNo, setPage, totalNumberOfPages, indexOfSelectedLegalEntity); @@ -82,13 +82,13 @@ public async Task GetEmployerViewModelAsync(VacancyRouteModel vm.VacancyEmployerInfoModel = new VacancyEmployerInfoModel() { VacancyId = vacancy.Id, - LegalEntityId = vacancy.LegalEntityId == 0 ? (long?)null : vacancy.LegalEntityId + AccountLegalEntityPublicHashedId = vacancy.AccountLegalEntityPublicHashedId }; - if (vm.VacancyEmployerInfoModel.LegalEntityId == null && vm.HasOnlyOneOrganisation) - { - vm.VacancyEmployerInfoModel.LegalEntityId = vm.Organisations.First().Id; - } + //if (vm.VacancyEmployerInfoModel.AccountLegalEntityPublicHashedId == null && vm.HasOnlyOneOrganisation) + //{ + // vm.VacancyEmployerInfoModel.AccountLegalEntityPublicHashedId = vm.Organisations.First().Id; + //} if (vacancy.EmployerNameOption.HasValue) { @@ -148,7 +148,7 @@ private IEnumerable BuildLegalEntityViewModels(EmployerEd private OrganisationViewModel ConvertToOrganisationViewModel(LegalEntity data) { - return new OrganisationViewModel { Id = data.LegalEntityId, Name = data.Name}; + return new OrganisationViewModel { Id = data.AccountLegalEntityPublicHashedId, Name = data.Name}; } } } \ No newline at end of file diff --git a/src/Employer/Employer.Web/Orchestrators/Part1/LocationOrchestrator.cs b/src/Employer/Employer.Web/Orchestrators/Part1/LocationOrchestrator.cs index 5e0f5b785a..edc35ea3c9 100644 --- a/src/Employer/Employer.Web/Orchestrators/Part1/LocationOrchestrator.cs +++ b/src/Employer/Employer.Web/Orchestrators/Part1/LocationOrchestrator.cs @@ -44,7 +44,7 @@ public async Task GetVacancyEmployerInfoModelAsync(Vac var model = new VacancyEmployerInfoModel() { VacancyId = vacancy.Id, - LegalEntityId = vacancy.LegalEntityId == 0 ? (long?) null : vacancy.LegalEntityId + AccountLegalEntityPublicHashedId = vacancy.AccountLegalEntityPublicHashedId }; if (vacancy.EmployerNameOption.HasValue) @@ -63,7 +63,9 @@ public async Task GetLocationViewModelAsync( var vacancy = await Utility.GetAuthorisedVacancyForEditAsync(_employerVacancyClient, _recruitVacancyClient, vrm, RouteNames.Location_Get); - var legalEntityId = employerInfoModel?.LegalEntityId != null ? employerInfoModel.LegalEntityId : vacancy.LegalEntityId; + var accountLegalEntityPublicHashedId = employerInfoModel?.AccountLegalEntityPublicHashedId != null + ? employerInfoModel.AccountLegalEntityPublicHashedId + : vacancy.AccountLegalEntityPublicHashedId; var vm = new LocationViewModel(); vm.PageInfo = Utility.GetPartOnePageInfo(vacancy); @@ -73,7 +75,7 @@ public async Task GetLocationViewModelAsync( : employerInfoModel.EmployerIdentityOption == EmployerIdentityOption.Anonymous; var employerProfile = - await _recruitVacancyClient.GetEmployerProfileAsync(vacancy.EmployerAccountId, legalEntityId.GetValueOrDefault()); + await _recruitVacancyClient.GetEmployerProfileAsync(vacancy.EmployerAccountId, accountLegalEntityPublicHashedId); var allLocations = await GetAllAvailableLocationsAsync(employerProfile); @@ -119,12 +121,15 @@ public async Task PostLocationEditModelAsync( var vacancy = vacancyTask.Result; var editVacancyInfo = employerVacancyInfoTask.Result; - var legalEntityId = employerInfoModel?.LegalEntityId == null ? vacancy.LegalEntityId : employerInfoModel.LegalEntityId; + var accountLegalEntityPublicHashedId = employerInfoModel?.AccountLegalEntityPublicHashedId != null + ? employerInfoModel.AccountLegalEntityPublicHashedId + : vacancy.AccountLegalEntityPublicHashedId; + var selectedOrganisation = - editVacancyInfo.LegalEntities.Single(l => l.LegalEntityId == legalEntityId); + editVacancyInfo.LegalEntities.Single(l => l.AccountLegalEntityPublicHashedId == accountLegalEntityPublicHashedId); var employerProfile = - await _recruitVacancyClient.GetEmployerProfileAsync(vacancy.EmployerAccountId, selectedOrganisation.LegalEntityId); + await _recruitVacancyClient.GetEmployerProfileAsync(vacancy.EmployerAccountId, selectedOrganisation.AccountLegalEntityPublicHashedId); var allLocations = await GetAllAvailableLocationsAsync(employerProfile); @@ -142,7 +147,6 @@ public async Task PostLocationEditModelAsync( { vacancy.LegalEntityName = selectedOrganisation.Name; vacancy.AccountLegalEntityPublicHashedId = selectedOrganisation.AccountLegalEntityPublicHashedId; - vacancy.LegalEntityId = employerInfoModel.LegalEntityId.GetValueOrDefault(); vacancy.EmployerNameOption = employerInfoModel.EmployerIdentityOption?.ConvertToDomainOption(); vacancy.AnonymousReason = vacancy.IsAnonymous ? employerInfoModel.AnonymousReason : null; vacancy.EmployerName = vacancy.IsAnonymous ? employerInfoModel.AnonymousName : null; diff --git a/src/Employer/Employer.Web/Orchestrators/Part2/AboutEmployerOrchestrator.cs b/src/Employer/Employer.Web/Orchestrators/Part2/AboutEmployerOrchestrator.cs index 28c5cbbf1f..8583bf4a52 100644 --- a/src/Employer/Employer.Web/Orchestrators/Part2/AboutEmployerOrchestrator.cs +++ b/src/Employer/Employer.Web/Orchestrators/Part2/AboutEmployerOrchestrator.cs @@ -82,7 +82,7 @@ public async Task PostAboutEmployerEditModelAsync(AboutEmp private async Task UpdateEmployerProfileAsync(Vacancy vacancy, string employerDescription, VacancyUser user) { var employerProfile = - await _vacancyClient.GetEmployerProfileAsync(vacancy.EmployerAccountId, vacancy.LegalEntityId); + await _vacancyClient.GetEmployerProfileAsync(vacancy.EmployerAccountId, vacancy.AccountLegalEntityPublicHashedId); if (employerProfile == null) { diff --git a/src/Employer/Employer.Web/Orchestrators/VacancyPreviewOrchestrator.cs b/src/Employer/Employer.Web/Orchestrators/VacancyPreviewOrchestrator.cs index 33c2ba1879..adae7d40ca 100644 --- a/src/Employer/Employer.Web/Orchestrators/VacancyPreviewOrchestrator.cs +++ b/src/Employer/Employer.Web/Orchestrators/VacancyPreviewOrchestrator.cs @@ -115,7 +115,7 @@ private async Task SubmitActionAsync(Vacancy vacancy, Vac { var response = new SubmitVacancyResponse { - HasLegalEntityAgreement = await _legalEntityAgreementService.HasLegalEntityAgreementAsync(vacancy.EmployerAccountId, vacancy.LegalEntityId), + HasLegalEntityAgreement = await _legalEntityAgreementService.HasLegalEntityAgreementAsync(vacancy.EmployerAccountId, vacancy.AccountLegalEntityPublicHashedId), IsSubmitted = false }; diff --git a/src/Employer/Employer.Web/ViewModels/Part1/Employer/EmployerEditModel.cs b/src/Employer/Employer.Web/ViewModels/Part1/Employer/EmployerEditModel.cs index 1bc09ee0e9..80d93f9628 100644 --- a/src/Employer/Employer.Web/ViewModels/Part1/Employer/EmployerEditModel.cs +++ b/src/Employer/Employer.Web/ViewModels/Part1/Employer/EmployerEditModel.cs @@ -1,14 +1,12 @@ using System.ComponentModel.DataAnnotations; using Esfa.Recruit.Employer.Web.RouteModel; -using Esfa.Recruit.Employer.Web.ViewModels; namespace Esfa.Recruit.Employer.Web.ViewModels.Part1.Employer { public class EmployerEditModel : VacancyRouteModel { [Required(ErrorMessage = ValidationMessages.EmployerSelectionValidationMessages.EmployerSelectionRequired)] - public long? SelectedOrganisationId { get; set; } - + public string AccountLegalEntityPublicHashedId { get; set; } public string SearchTerm { get; set; } public int Page { get; set; } } diff --git a/src/Employer/Employer.Web/ViewModels/Part1/Employer/EmployerViewModel.cs b/src/Employer/Employer.Web/ViewModels/Part1/Employer/EmployerViewModel.cs index 4c2d489800..eb0cf2cde3 100644 --- a/src/Employer/Employer.Web/ViewModels/Part1/Employer/EmployerViewModel.cs +++ b/src/Employer/Employer.Web/ViewModels/Part1/Employer/EmployerViewModel.cs @@ -17,13 +17,13 @@ public class EmployerViewModel : VacancyRouteModel public PartOnePageInfoViewModel PageInfo { get; internal set; } public PagerViewModel Pager { get; internal set; } - + public string AccountLegalEntityPublicHashedId { get; set; } public IList OrderedFieldNames => new List { - nameof(SelectedOrganisationId) + nameof(AccountLegalEntityPublicHashedId) }; - public long? SelectedOrganisationId { get; internal set; } + public string SelectedOrganisationId { get; internal set; } public VacancyEmployerInfoModel VacancyEmployerInfoModel { get; internal set; } @@ -38,18 +38,18 @@ public class EmployerViewModel : VacancyRouteModel public int TotalNumberOfLegalEntities { get; internal set; } public bool IsPreviouslySelectedLegalEntityStillValid { get; internal set; } - public bool HasPreviouslyPersistedLegalEntity => SelectedOrganisationId.Value > 0; + public bool HasPreviouslyPersistedLegalEntity => !string.IsNullOrEmpty(AccountLegalEntityPublicHashedId); public bool IsSelectedOrganisationInPagedOrganisations => IsPreviouslySelectedLegalEntityStillValid && HasPreviouslyPersistedLegalEntity - && Organisations.Any(org => org.Id == SelectedOrganisationId.Value); + && Organisations.Any(org => org.Id == AccountLegalEntityPublicHashedId); - public bool CanOutputHiddenSelectedOrganisationIdField => SelectedOrganisationId.Value > 0 && IsSelectedOrganisationInPagedOrganisations == false; + public bool CanOutputHiddenSelectedOrganisationIdField => !string.IsNullOrEmpty(AccountLegalEntityPublicHashedId) && IsSelectedOrganisationInPagedOrganisations == false; } public class OrganisationViewModel { - public long Id { get; set; } + public string Id { get; set; } public string Name { get; set; } } } diff --git a/src/Jobs/Recruit.Vacancies.Jobs/DomainEvents/Handlers/Employer/SetupEmployerHandler.cs b/src/Jobs/Recruit.Vacancies.Jobs/DomainEvents/Handlers/Employer/SetupEmployerHandler.cs index fb8e57c920..ba0c2de054 100644 --- a/src/Jobs/Recruit.Vacancies.Jobs/DomainEvents/Handlers/Employer/SetupEmployerHandler.cs +++ b/src/Jobs/Recruit.Vacancies.Jobs/DomainEvents/Handlers/Employer/SetupEmployerHandler.cs @@ -33,7 +33,7 @@ public async Task HandleAsync(string eventPayload) var vacancyDataTask = _projectionService.UpdateEmployerVacancyDataAsync(@event.EmployerAccountId, legalEntities); - var employerProfilesTask = _client.RefreshEmployerProfiles(@event.EmployerAccountId, legalEntities.Select(x => x.LegalEntityId)); + var employerProfilesTask = _client.RefreshEmployerProfiles(@event.EmployerAccountId, legalEntities.Select(x => x.AccountLegalEntityPublicHashedId)); await Task.WhenAll(vacancyDataTask, employerProfilesTask); diff --git a/src/Provider/Provider.Web/Controllers/Part1/LegalEntityController.cs b/src/Provider/Provider.Web/Controllers/Part1/LegalEntityController.cs index 5a695db390..0441bee8bd 100644 --- a/src/Provider/Provider.Web/Controllers/Part1/LegalEntityController.cs +++ b/src/Provider/Provider.Web/Controllers/Part1/LegalEntityController.cs @@ -26,15 +26,15 @@ public async Task LegalEntity(VacancyRouteModel vrm, [FromQuery]s { var info = GetVacancyEmployerInfoCookie(vrm.VacancyId.GetValueOrDefault()); - var vm = await _orchestrator.GetLegalEntityViewModelAsync(vrm, User.GetUkprn(), searchTerm, page, info?.LegalEntityId); + var vm = await _orchestrator.GetLegalEntityViewModelAsync(vrm, User.GetUkprn(), searchTerm, page, info?.AccountLegalEntityPublicHashedId); - if (info == null || !info.LegalEntityId.HasValue) + if (info == null || !string.IsNullOrEmpty(info.AccountLegalEntityPublicHashedId)) { SetVacancyEmployerInfoCookie(vm.VacancyEmployerInfoModel); } else { - vm.SelectedOrganisationId = info.LegalEntityId; + vm.SelectedOrganisationId = info.AccountLegalEntityPublicHashedId; } if (vm.HasOnlyOneOrganisation) @@ -61,16 +61,16 @@ public async Task LegalEntity(LegalEntityEditModel m, [FromQuery] if (!ModelState.IsValid) { - var vm = await _orchestrator.GetLegalEntityViewModelAsync(m, User.GetUkprn(), m.SearchTerm, m.Page, info.LegalEntityId); + var vm = await _orchestrator.GetLegalEntityViewModelAsync(m, User.GetUkprn(), m.SearchTerm, m.Page, info.AccountLegalEntityPublicHashedId); SetVacancyEmployerInfoCookie(vm.VacancyEmployerInfoModel); vm.Pager.OtherRouteValues.Add(nameof(wizard), wizard.ToString()); vm.PageInfo.SetWizard(wizard); return View(vm); } - if (info.LegalEntityId != m.SelectedOrganisationId) + if (info.AccountLegalEntityPublicHashedId != m.SelectedOrganisationId) { - info.LegalEntityId = m.SelectedOrganisationId; + info.AccountLegalEntityPublicHashedId = m.SelectedOrganisationId; info.HasLegalEntityChanged = true; info.EmployerIdentityOption = null; info.NewTradingName = null; diff --git a/src/Provider/Provider.Web/Models/VacancyEmployerInfoModel.cs b/src/Provider/Provider.Web/Models/VacancyEmployerInfoModel.cs index 54c18164c9..f7a5274fe7 100644 --- a/src/Provider/Provider.Web/Models/VacancyEmployerInfoModel.cs +++ b/src/Provider/Provider.Web/Models/VacancyEmployerInfoModel.cs @@ -6,7 +6,7 @@ namespace Esfa.Recruit.Provider.Web.Models public class VacancyEmployerInfoModel { public Guid? VacancyId { get; set; } - public long? LegalEntityId { get; set; } + public string AccountLegalEntityPublicHashedId { get; set; } public EmployerIdentityOption? EmployerIdentityOption { get; set; } public string NewTradingName { get; set; } public bool HasLegalEntityChanged { get; set;} diff --git a/src/Provider/Provider.Web/Orchestrators/LegalEntityAgreementOrchestrator.cs b/src/Provider/Provider.Web/Orchestrators/LegalEntityAgreementOrchestrator.cs index dbdf2caae7..626bcc94f5 100644 --- a/src/Provider/Provider.Web/Orchestrators/LegalEntityAgreementOrchestrator.cs +++ b/src/Provider/Provider.Web/Orchestrators/LegalEntityAgreementOrchestrator.cs @@ -31,7 +31,7 @@ public async Task GetLegalEntityAgreement return new LegalEntityAgreementHardStopViewModel { HasLegalEntityAgreement = await _legalEntityAgreementService.HasLegalEntityAgreementAsync( - vacancy.EmployerAccountId, vacancy.LegalEntityId), + vacancy.EmployerAccountId, vacancy.AccountLegalEntityPublicHashedId), LegalEntityName = vacancy.LegalEntityName }; } diff --git a/src/Provider/Provider.Web/Orchestrators/Part1/EmployerNameOrchestrator.cs b/src/Provider/Provider.Web/Orchestrators/Part1/EmployerNameOrchestrator.cs index a177e99759..c0eb9b6920 100644 --- a/src/Provider/Provider.Web/Orchestrators/Part1/EmployerNameOrchestrator.cs +++ b/src/Provider/Provider.Web/Orchestrators/Part1/EmployerNameOrchestrator.cs @@ -45,18 +45,18 @@ public async Task GetEmployerNameViewModelAsync( var vacancy = await Utility.GetAuthorisedVacancyForEditAsync( _providerVacancyClient, _recruitVacancyClient, vrm, RouteNames.EmployerName_Get); - var legalEntityId = employerInfoModel.LegalEntityId.GetValueOrDefault(); + var accountLegalEntityPublicHashedId = employerInfoModel.AccountLegalEntityPublicHashedId; var getVacancyEditInfoTask = _providerVacancyClient.GetProviderEditVacancyInfoAsync(vrm.Ukprn); - var getEmployerProfileTask = _recruitVacancyClient.GetEmployerProfileAsync(vacancy.EmployerAccountId, legalEntityId); + 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.LegalEntityId == legalEntityId); + var legalEntity = employerInfo.LegalEntities.Single(l => l.AccountLegalEntityPublicHashedId == accountLegalEntityPublicHashedId); var vm = new EmployerNameViewModel { diff --git a/src/Provider/Provider.Web/Orchestrators/Part1/LegalEntityOrchestrator.cs b/src/Provider/Provider.Web/Orchestrators/Part1/LegalEntityOrchestrator.cs index d801ed87a2..8e289ecc02 100644 --- a/src/Provider/Provider.Web/Orchestrators/Part1/LegalEntityOrchestrator.cs +++ b/src/Provider/Provider.Web/Orchestrators/Part1/LegalEntityOrchestrator.cs @@ -33,7 +33,7 @@ public LegalEntityOrchestrator( _logger = logger; } - public async Task GetLegalEntityViewModelAsync(VacancyRouteModel vrm, long ukprn, string searchTerm, int? requestedPageNo, long? selectedLegalEntityId = 0) + public async Task GetLegalEntityViewModelAsync(VacancyRouteModel vrm, long ukprn, string searchTerm, int? requestedPageNo, string selectedAccountLegalEntityPublicHashedId) { const int NotFoundIndex = -1; var setPage = requestedPageNo.HasValue ? requestedPageNo.Value : 1; @@ -44,17 +44,17 @@ public async Task GetLegalEntityViewModelAsync(VacancyRout var vm = new LegalEntityViewModel { TotalNumberOfLegalEntities = legalEntities.Count(), - SelectedOrganisationId = vacancy.LegalEntityId, + SelectedOrganisationId = vacancy.AccountLegalEntityPublicHashedId, PageInfo = Utility.GetPartOnePageInfo(vacancy), SearchTerm = searchTerm }; - if (vacancy.LegalEntityId != 0 && (selectedLegalEntityId.HasValue == false || selectedLegalEntityId == 0)) + if (!string.IsNullOrEmpty(vacancy.AccountLegalEntityPublicHashedId) && string.IsNullOrEmpty(selectedAccountLegalEntityPublicHashedId)) { - selectedLegalEntityId = vacancy.LegalEntityId; + selectedAccountLegalEntityPublicHashedId = vacancy.AccountLegalEntityPublicHashedId; } - vm.IsPreviouslySelectedLegalEntityStillValid = selectedLegalEntityId.HasValue && legalEntities.Any(le => le.Id == selectedLegalEntityId); + vm.IsPreviouslySelectedLegalEntityStillValid = !string.IsNullOrEmpty(selectedAccountLegalEntityPublicHashedId) && legalEntities.Any(le => le.Id == selectedAccountLegalEntityPublicHashedId); var filteredLegalEntities = legalEntities .Where(le => string.IsNullOrEmpty(searchTerm) || le.Name.Contains(searchTerm, StringComparison.OrdinalIgnoreCase)) @@ -64,8 +64,8 @@ public async Task GetLegalEntityViewModelAsync(VacancyRout var filteredLegalEntitiesTotal = filteredLegalEntities.Count(); var totalNumberOfPages = PagingHelper.GetTotalNoOfPages(MaxLegalEntitiesPerPage, filteredLegalEntitiesTotal); - var indexOfSelectedLegalEntity = selectedLegalEntityId.HasValue - ? filteredLegalEntities.FindIndex(le => le.Id == selectedLegalEntityId.Value) + 1 + var indexOfSelectedLegalEntity = !string.IsNullOrEmpty(selectedAccountLegalEntityPublicHashedId) + ? filteredLegalEntities.FindIndex(le => le.Id == selectedAccountLegalEntityPublicHashedId) + 1 : NotFoundIndex; setPage = GetPageNo(requestedPageNo, setPage, totalNumberOfPages, indexOfSelectedLegalEntity); @@ -76,12 +76,12 @@ public async Task GetLegalEntityViewModelAsync(VacancyRout vm.VacancyEmployerInfoModel = new VacancyEmployerInfoModel { VacancyId = vacancy.Id, - LegalEntityId = vacancy.LegalEntityId == 0 ? (long?)null : vacancy.LegalEntityId + AccountLegalEntityPublicHashedId = vacancy.AccountLegalEntityPublicHashedId }; - if (vm.VacancyEmployerInfoModel.LegalEntityId == null && vm.HasOnlyOneOrganisation) + if (string.IsNullOrEmpty(vm.VacancyEmployerInfoModel.AccountLegalEntityPublicHashedId) && vm.HasOnlyOneOrganisation) { - vm.VacancyEmployerInfoModel.LegalEntityId = vm.Organisations.First().Id; + vm.VacancyEmployerInfoModel.AccountLegalEntityPublicHashedId = vm.Organisations.First().Id; } if (vacancy.EmployerNameOption.HasValue) @@ -131,7 +131,7 @@ private void SetFilteredOrganisationsForPage(int page, LegalEntityViewModel vm, private OrganisationViewModel ConvertToOrganisationViewModel(LegalEntity data) { - return new OrganisationViewModel { Id = data.LegalEntityId, Name = data.Name }; + return new OrganisationViewModel { Id = data.AccountLegalEntityPublicHashedId, Name = data.Name }; } private async Task> GetLegalEntityViewModelsAsync(long ukprn, string employerAccountId) diff --git a/src/Provider/Provider.Web/Orchestrators/Part1/LocationOrchestrator.cs b/src/Provider/Provider.Web/Orchestrators/Part1/LocationOrchestrator.cs index 3028d45b1f..ab2c8ff504 100644 --- a/src/Provider/Provider.Web/Orchestrators/Part1/LocationOrchestrator.cs +++ b/src/Provider/Provider.Web/Orchestrators/Part1/LocationOrchestrator.cs @@ -26,7 +26,7 @@ public class LocationOrchestrator : EntityValidatingOrchestrator logger, IReviewSummaryService reviewSummaryService) : base(logger) { @@ -40,9 +40,10 @@ public async Task GetVacancyEmployerInfoModelAsync(Vac var vacancy = await Utility.GetAuthorisedVacancyForEditAsync( _providerVacancyClient, _recruitVacancyClient, vrm, RouteNames.Location_Get); - var model = new VacancyEmployerInfoModel() { + var model = new VacancyEmployerInfoModel() + { VacancyId = vacancy.Id, - LegalEntityId = vacancy.LegalEntityId == 0 ? (long?)null : vacancy.LegalEntityId + AccountLegalEntityPublicHashedId = vacancy.AccountLegalEntityPublicHashedId }; if (vacancy.EmployerNameOption.HasValue) @@ -51,7 +52,7 @@ public async Task GetVacancyEmployerInfoModelAsync(Vac model.AnonymousName = vacancy.IsAnonymous ? vacancy.EmployerName : null; model.AnonymousReason = vacancy.IsAnonymous ? vacancy.AnonymousReason : null; } - + return model; } @@ -61,7 +62,7 @@ public async Task GetLocationViewModelAsync( var vacancy = await Utility.GetAuthorisedVacancyForEditAsync( _providerVacancyClient, _recruitVacancyClient, vrm, RouteNames.Location_Get); - var legalEntityId = employerInfoModel?.LegalEntityId ?? vacancy.LegalEntityId; + var accountLegalEntityPublicHashedId = employerInfoModel?.AccountLegalEntityPublicHashedId ?? vacancy.AccountLegalEntityPublicHashedId; var vm = new LocationViewModel(); vm.PageInfo = Utility.GetPartOnePageInfo(vacancy); @@ -71,7 +72,7 @@ public async Task GetLocationViewModelAsync( : employerInfoModel.EmployerIdentityOption == EmployerIdentityOption.Anonymous; var employerProfile = - await _recruitVacancyClient.GetEmployerProfileAsync(vacancy.EmployerAccountId, legalEntityId); + await _recruitVacancyClient.GetEmployerProfileAsync(vacancy.EmployerAccountId, accountLegalEntityPublicHashedId); var allLocations = await GetAllAvailableLocationsAsync(employerProfile, vacancy, vrm.Ukprn); @@ -110,15 +111,15 @@ public async Task PostLocationEditModelAsync( var vacancy = await Utility.GetAuthorisedVacancyForEditAsync(_providerVacancyClient, _recruitVacancyClient, locationEditModel, RouteNames.Location_Post); - var legalEntityId = employerInfoModel?.LegalEntityId ?? vacancy.LegalEntityId; + var accountLegalEntityPublicHashedId = employerInfoModel?.AccountLegalEntityPublicHashedId ?? vacancy.AccountLegalEntityPublicHashedId; var employerVacancyInfoTask = _providerVacancyClient.GetProviderEmployerVacancyDataAsync(ukprn, vacancy.EmployerAccountId); - var employerProfileTask = _recruitVacancyClient.GetEmployerProfileAsync(vacancy.EmployerAccountId, legalEntityId); + var employerProfileTask = _recruitVacancyClient.GetEmployerProfileAsync(vacancy.EmployerAccountId, accountLegalEntityPublicHashedId); await Task.WhenAll(employerProfileTask, employerVacancyInfoTask); var employerVacancyInfo = employerVacancyInfoTask.Result; var employerProfile = employerProfileTask.Result; - var selectedOrganisation = employerVacancyInfo.LegalEntities.Single(l => l.LegalEntityId == legalEntityId); + var selectedOrganisation = employerVacancyInfo.LegalEntities.Single(l => l.AccountLegalEntityPublicHashedId == accountLegalEntityPublicHashedId); var allLocations = await GetAllAvailableLocationsAsync(employerProfile, vacancy, ukprn); var newLocation = locationEditModel.SelectedLocation == LocationViewModel.UseOtherLocationConst @@ -134,7 +135,6 @@ public async Task PostLocationEditModelAsync( { vacancy.LegalEntityName = selectedOrganisation.Name; vacancy.AccountLegalEntityPublicHashedId = selectedOrganisation.AccountLegalEntityPublicHashedId; - vacancy.LegalEntityId = employerInfoModel.LegalEntityId.GetValueOrDefault(); vacancy.EmployerNameOption = employerInfoModel.EmployerIdentityOption?.ConvertToDomainOption(); vacancy.AnonymousReason = vacancy.IsAnonymous ? employerInfoModel.AnonymousReason : null; vacancy.EmployerName = vacancy.IsAnonymous ? employerInfoModel.AnonymousName : null; @@ -147,7 +147,7 @@ public async Task PostLocationEditModelAsync( { await _recruitVacancyClient.UpdateDraftVacancyAsync(vacancy, user); await UpdateEmployerProfileAsync(employerInfoModel, employerProfile, matchingAddress == null ? vacancy.EmployerLocation : null, user); - }); + }); } private Address GetMatchingAddress(string locationToMatch, IEnumerable
allLocations) @@ -160,7 +160,8 @@ private Address GetMatchingAddress(string locationToMatch, IEnumerable
private Address ConvertToDomainAddress(LocationEditModel locationEditModel) { - return new Address { + return new Address + { AddressLine1 = locationEditModel.AddressLine1, AddressLine2 = locationEditModel.AddressLine2, AddressLine3 = locationEditModel.AddressLine3, diff --git a/src/Provider/Provider.Web/Orchestrators/VacancyPreviewOrchestrator.cs b/src/Provider/Provider.Web/Orchestrators/VacancyPreviewOrchestrator.cs index d418af2c79..3294042c7d 100644 --- a/src/Provider/Provider.Web/Orchestrators/VacancyPreviewOrchestrator.cs +++ b/src/Provider/Provider.Web/Orchestrators/VacancyPreviewOrchestrator.cs @@ -105,7 +105,7 @@ public async Task> SubmitVacancyAsyn private async Task SubmitActionAsync(Vacancy vacancy, VacancyUser user) { - var hasLegalEntityAgreementTask = _legalEntityAgreementService.HasLegalEntityAgreementAsync(vacancy.EmployerAccountId, vacancy.LegalEntityId); + var hasLegalEntityAgreementTask = _legalEntityAgreementService.HasLegalEntityAgreementAsync(vacancy.EmployerAccountId, vacancy.AccountLegalEntityPublicHashedId); var hasProviderAgreementTask = _trainingProviderAgreementService.HasAgreementAsync(vacancy.TrainingProvider.Ukprn.Value); await Task.WhenAll(hasLegalEntityAgreementTask, hasProviderAgreementTask); diff --git a/src/Provider/Provider.Web/ViewModels/Part1/LegalEntity/LegalEntityEditModel.cs b/src/Provider/Provider.Web/ViewModels/Part1/LegalEntity/LegalEntityEditModel.cs index d63581da0b..f83cb1c2d3 100644 --- a/src/Provider/Provider.Web/ViewModels/Part1/LegalEntity/LegalEntityEditModel.cs +++ b/src/Provider/Provider.Web/ViewModels/Part1/LegalEntity/LegalEntityEditModel.cs @@ -6,7 +6,7 @@ namespace Esfa.Recruit.Provider.Web.ViewModels.Part1.LegalEntity public class LegalEntityEditModel : VacancyRouteModel { [Required(ErrorMessage = ValidationMessages.EmployerSelectionValidationMessages.EmployerSelectionRequired)] - public long? SelectedOrganisationId { get; set; } + public string SelectedOrganisationId { get; set; } public string SearchTerm { get; set; } public int Page { get; set; } diff --git a/src/Provider/Provider.Web/ViewModels/Part1/LegalEntity/LegalEntityViewModel.cs b/src/Provider/Provider.Web/ViewModels/Part1/LegalEntity/LegalEntityViewModel.cs index 0f0a428cd1..05882c2ec0 100644 --- a/src/Provider/Provider.Web/ViewModels/Part1/LegalEntity/LegalEntityViewModel.cs +++ b/src/Provider/Provider.Web/ViewModels/Part1/LegalEntity/LegalEntityViewModel.cs @@ -22,7 +22,7 @@ public class LegalEntityViewModel nameof(SelectedOrganisationId) }; - public long? SelectedOrganisationId { get; internal set; } + public string SelectedOrganisationId { get; internal set; } public VacancyEmployerInfoModel VacancyEmployerInfoModel { get; internal set; } @@ -37,18 +37,18 @@ public class LegalEntityViewModel public int TotalNumberOfLegalEntities { get; internal set; } public bool IsPreviouslySelectedLegalEntityStillValid { get; internal set; } - public bool HasPreviouslyPersistedLegalEntity => SelectedOrganisationId.Value > 0; + public bool HasPreviouslyPersistedLegalEntity => !string.IsNullOrEmpty(SelectedOrganisationId); public bool IsSelectedOrganisationInPagedOrganisations => IsPreviouslySelectedLegalEntityStillValid && HasPreviouslyPersistedLegalEntity - && Organisations.Any(org => org.Id == SelectedOrganisationId.Value); + && Organisations.Any(org => org.Id == SelectedOrganisationId); - public bool CanOutputHiddenSelectedOrganisationIdField => SelectedOrganisationId.Value > 0 && IsSelectedOrganisationInPagedOrganisations == false; + public bool CanOutputHiddenSelectedOrganisationIdField => !string.IsNullOrEmpty(SelectedOrganisationId) && IsSelectedOrganisationInPagedOrganisations == false; } public class OrganisationViewModel { - public long Id { get; set; } + public string Id { get; set; } public string Name { get; set; } } } \ No newline at end of file diff --git a/src/Provider/UnitTests/Provider.Web/Orchestrators/Part1/LegalEntityOrchestratorTests.cs b/src/Provider/UnitTests/Provider.Web/Orchestrators/Part1/LegalEntityOrchestratorTests.cs index 4c9bfe4fba..a9f14c15bd 100644 --- a/src/Provider/UnitTests/Provider.Web/Orchestrators/Part1/LegalEntityOrchestratorTests.cs +++ b/src/Provider/UnitTests/Provider.Web/Orchestrators/Part1/LegalEntityOrchestratorTests.cs @@ -23,7 +23,7 @@ public class LegalEntityOrchestratorTests private readonly LegalEntityOrchestrator _orchestrator; private readonly Vacancy _testVacancy; private readonly VacancyRouteModel _testRouteModel = new VacancyRouteModel { Ukprn = TestUkprn, VacancyId = Guid.NewGuid() }; - + private readonly string AccountLegalEntityPublicHashedId = "ABCEFG"; public LegalEntityOrchestratorTests() { _mockLogger = new Mock>(); @@ -49,7 +49,7 @@ public async Task WhenNoLegalEntities_ShouldReturnEmptyList() _mockVacancyClient.Setup(x => x.GetVacancyAsync(It.IsAny())).ReturnsAsync(_testVacancy); - var result = await _orchestrator.GetLegalEntityViewModelAsync(_testRouteModel, TestUkprn, "", 1); + var result = await _orchestrator.GetLegalEntityViewModelAsync(_testRouteModel, TestUkprn, "", 1, AccountLegalEntityPublicHashedId); result.Organisations.Count().Should().Be(0); } diff --git a/src/Provider/UnitTests/Provider.Web/Orchestrators/VacancyPreviewOrchestratorTests.cs b/src/Provider/UnitTests/Provider.Web/Orchestrators/VacancyPreviewOrchestratorTests.cs index c06a70085f..f2dbf0e37d 100644 --- a/src/Provider/UnitTests/Provider.Web/Orchestrators/VacancyPreviewOrchestratorTests.cs +++ b/src/Provider/UnitTests/Provider.Web/Orchestrators/VacancyPreviewOrchestratorTests.cs @@ -37,7 +37,7 @@ public async Task SubmitVacancyAsync_ShouldNotSubmitWhenMissingAgreements( const long ukprn = 12345678; const string employerAccountId = "ABCDEF"; const long legalEntityId = 1234; - + const string accountLegalEntityPublicHashedId = "XVYABD"; var fixture = new Fixture(); var vacancy = fixture.Create(); vacancy.Id = vacancyId; @@ -45,6 +45,7 @@ public async Task SubmitVacancyAsync_ShouldNotSubmitWhenMissingAgreements( vacancy.Status = VacancyStatus.Draft; vacancy.IsDeleted = false; vacancy.EmployerAccountId = employerAccountId; + vacancy.AccountLegalEntityPublicHashedId = accountLegalEntityPublicHashedId; vacancy.LegalEntityId = legalEntityId; vacancy.OwnerType = OwnerType.Provider; @@ -69,7 +70,7 @@ public async Task SubmitVacancyAsync_ShouldNotSubmitWhenMissingAgreements( var review = new Mock(); var legalEntityAgreement = new Mock(); - legalEntityAgreement.Setup(l => l.HasLegalEntityAgreementAsync(employerAccountId, legalEntityId)) + legalEntityAgreement.Setup(l => l.HasLegalEntityAgreementAsync(employerAccountId, accountLegalEntityPublicHashedId)) .ReturnsAsync(hasLegalEntityAgreement); var agreementServiceMock = new Mock(); diff --git a/src/Shared/Recruit.Shared.Web/Services/ILegalEntityAgreementService.cs b/src/Shared/Recruit.Shared.Web/Services/ILegalEntityAgreementService.cs index bdbd3c46f5..bb2e9775d7 100644 --- a/src/Shared/Recruit.Shared.Web/Services/ILegalEntityAgreementService.cs +++ b/src/Shared/Recruit.Shared.Web/Services/ILegalEntityAgreementService.cs @@ -6,8 +6,8 @@ namespace Esfa.Recruit.Shared.Web.Services { public interface ILegalEntityAgreementService { - Task HasLegalEntityAgreementAsync(string employerAccountId, long legalEntityId); - Task GetLegalEntityAsync(string employerAccountId, long legalEntityId); + Task HasLegalEntityAgreementAsync(string employerAccountId, string accountLegalEntityPublicHashedId); + Task GetLegalEntityAsync(string employerAccountId, string accountLegalEntityPublicHashedId); Task HasLegalEntityAgreementAsync(string employerAccountId, LegalEntity legalEntity); } } \ No newline at end of file diff --git a/src/Shared/Recruit.Shared.Web/Services/LegalEntityAgreementService.cs b/src/Shared/Recruit.Shared.Web/Services/LegalEntityAgreementService.cs index 258f364b6c..60c71a9e96 100644 --- a/src/Shared/Recruit.Shared.Web/Services/LegalEntityAgreementService.cs +++ b/src/Shared/Recruit.Shared.Web/Services/LegalEntityAgreementService.cs @@ -14,9 +14,9 @@ public LegalEntityAgreementService(IEmployerVacancyClient client) _client = client; } - public async Task HasLegalEntityAgreementAsync(string employerAccountId, long legalEntityId) + public async Task HasLegalEntityAgreementAsync(string employerAccountId, string accountLegalEntityPublicHashedId) { - var legalEntity = await GetLegalEntityAsync(employerAccountId, legalEntityId); + var legalEntity = await GetLegalEntityAsync(employerAccountId, accountLegalEntityPublicHashedId); return await HasLegalEntityAgreementAsync(employerAccountId, legalEntity); } @@ -40,11 +40,11 @@ public async Task HasLegalEntityAgreementAsync(string employerAccountId, L return hasLegalEntityAgreement; } - public async Task GetLegalEntityAsync(string employerAccountId, long legalEntityId) + public async Task GetLegalEntityAsync(string employerAccountId, string accountLegalEntityPublicHashedId) { var employerData = await _client.GetEditVacancyInfoAsync(employerAccountId); - var legalEntity = employerData.LegalEntities.SingleOrDefault(l => l.LegalEntityId == legalEntityId); + var legalEntity = employerData.LegalEntities.SingleOrDefault(l => l.AccountLegalEntityPublicHashedId == accountLegalEntityPublicHashedId); return legalEntity; } diff --git a/src/Shared/Recruit.Vacancies.Client/Application/CommandHandlers/RefreshEmployerProfilesCommandHandler.cs b/src/Shared/Recruit.Vacancies.Client/Application/CommandHandlers/RefreshEmployerProfilesCommandHandler.cs index 45b68a6e38..b412a2a7d4 100644 --- a/src/Shared/Recruit.Vacancies.Client/Application/CommandHandlers/RefreshEmployerProfilesCommandHandler.cs +++ b/src/Shared/Recruit.Vacancies.Client/Application/CommandHandlers/RefreshEmployerProfilesCommandHandler.cs @@ -40,11 +40,11 @@ public async Task Handle(RefreshEmployerProfilesCommand message, CancellationTok // Get all current profiles for the employer var profiles = await _employerProfileRepository.GetEmployerProfilesForEmployerAsync(message.EmployerAccountId); - foreach (var legalEntity in message.LegalEntityIds) + foreach (var accountLegalEntityPublicHashedId in message.AccountLegalEntityPublicHashedIds) { var selectedOrganisation = - editVacancyInfo.LegalEntities.Single(l => l.LegalEntityId == legalEntity); - if (!profiles.Any(x => x.LegalEntityId == legalEntity)) + editVacancyInfo.LegalEntities.Single(l => l.AccountLegalEntityPublicHashedId == accountLegalEntityPublicHashedId); + if (!profiles.Any(x => x.AccountLegalEntityPublicHashedId == accountLegalEntityPublicHashedId)) { var currentTime = _time.Now; @@ -52,18 +52,15 @@ public async Task Handle(RefreshEmployerProfilesCommand message, CancellationTok var newProfile = new EmployerProfile { EmployerAccountId = message.EmployerAccountId, - LegalEntityId = legalEntity, CreatedDate = currentTime, AccountLegalEntityPublicHashedId = selectedOrganisation.AccountLegalEntityPublicHashedId }; - _logger.LogInformation("Adding new profile for employer account: {employerAccountId} and legal entity id: {legalEntityId}", message.EmployerAccountId, legalEntity); + _logger.LogInformation("Adding new profile for employer account: {employerAccountId} and Account LegalEntityPublicHashed id: {accountLegalEntityPublicHashedId}", message.EmployerAccountId, accountLegalEntityPublicHashedId); tasks.Add(_employerProfileRepository.CreateAsync(newProfile)); } } - await Task.WhenAll(tasks); - _logger.LogInformation($"Added {tasks.Count} new profile/s for {{employerAccountId}}", message.EmployerAccountId); } } diff --git a/src/Shared/Recruit.Vacancies.Client/Application/CommandHandlers/UpdateEmployerProfileCommandHandler.cs b/src/Shared/Recruit.Vacancies.Client/Application/CommandHandlers/UpdateEmployerProfileCommandHandler.cs index c1f0d3a748..fb6ffc1944 100644 --- a/src/Shared/Recruit.Vacancies.Client/Application/CommandHandlers/UpdateEmployerProfileCommandHandler.cs +++ b/src/Shared/Recruit.Vacancies.Client/Application/CommandHandlers/UpdateEmployerProfileCommandHandler.cs @@ -32,8 +32,8 @@ public async Task Handle(UpdateEmployerProfileCommand message, CancellationToken await _employerProfileRepository.UpdateAsync(message.Profile); _logger.LogInformation("Update Employer profile for employer account: {employerAccountId} and " + - "legal entity: {legalEntityId} AccountLegalEntityPublicHashedId:{AccountLegalEntityPublicHashedId}", message.Profile.EmployerAccountId, - message.Profile.LegalEntityId, message.Profile.AccountLegalEntityPublicHashedId); + "AccountLegalEntityPublicHashedId:{AccountLegalEntityPublicHashedId}", message.Profile.EmployerAccountId, + message.Profile.AccountLegalEntityPublicHashedId); } } } \ No newline at end of file diff --git a/src/Shared/Recruit.Vacancies.Client/Application/Commands/RefreshEmployerProfilesCommand.cs b/src/Shared/Recruit.Vacancies.Client/Application/Commands/RefreshEmployerProfilesCommand.cs index 9176a45287..f39e9a7195 100644 --- a/src/Shared/Recruit.Vacancies.Client/Application/Commands/RefreshEmployerProfilesCommand.cs +++ b/src/Shared/Recruit.Vacancies.Client/Application/Commands/RefreshEmployerProfilesCommand.cs @@ -7,6 +7,6 @@ namespace Esfa.Recruit.Vacancies.Client.Application.Commands public class RefreshEmployerProfilesCommand : ICommand, IRequest { public string EmployerAccountId { get; set; } - public IEnumerable LegalEntityIds { get; set; } + public IEnumerable AccountLegalEntityPublicHashedIds { get; set; } } } diff --git a/src/Shared/Recruit.Vacancies.Client/Application/Services/EmployerService.cs b/src/Shared/Recruit.Vacancies.Client/Application/Services/EmployerService.cs index 35bc2e378b..956f5b8a0a 100644 --- a/src/Shared/Recruit.Vacancies.Client/Application/Services/EmployerService.cs +++ b/src/Shared/Recruit.Vacancies.Client/Application/Services/EmployerService.cs @@ -23,7 +23,7 @@ public async Task GetEmployerNameAsync(Vacancy vacancy) if (vacancy.EmployerNameOption == EmployerNameOption.TradingName) { - var profile = await _employerProfileRepository.GetAsync(vacancy.EmployerAccountId, vacancy.LegalEntityId); + var profile = await _employerProfileRepository.GetAsync(vacancy.EmployerAccountId, vacancy.AccountLegalEntityPublicHashedId); return profile.TradingName; } @@ -35,7 +35,7 @@ public async Task GetEmployerDescriptionAsync(Vacancy vacancy) if (!vacancy.CanEdit) return vacancy.EmployerDescription; - var profile = await _employerProfileRepository.GetAsync(vacancy.EmployerAccountId, vacancy.LegalEntityId); + var profile = await _employerProfileRepository.GetAsync(vacancy.EmployerAccountId, vacancy.AccountLegalEntityPublicHashedId); return profile?.AboutOrganisation ?? string.Empty; } } diff --git a/src/Shared/Recruit.Vacancies.Client/Domain/Entities/EmployerProfile.cs b/src/Shared/Recruit.Vacancies.Client/Domain/Entities/EmployerProfile.cs index 9eff6058be..26d2bd2254 100644 --- a/src/Shared/Recruit.Vacancies.Client/Domain/Entities/EmployerProfile.cs +++ b/src/Shared/Recruit.Vacancies.Client/Domain/Entities/EmployerProfile.cs @@ -6,24 +6,20 @@ namespace Esfa.Recruit.Vacancies.Client.Domain.Entities public class EmployerProfile { private const string IdFormat = "{0}_{1}"; - public string Id => GetId(EmployerAccountId, LegalEntityId); + public string Id => GetId(EmployerAccountId, AccountLegalEntityPublicHashedId); public string EmployerAccountId { get; set; } - public long LegalEntityId { get; set; } public string AboutOrganisation { get; set; } public string OrganistationWebsiteUrl { get; set; } public string TradingName { get; set; } public DateTime CreatedDate { get; set; } public DateTime? LastUpdatedDate { get; set; } public VacancyUser LastUpdatedBy { get; set; } - public static string GetId(string employerAccountId, long legalEntityId) - { - return string.Format(IdFormat, employerAccountId, legalEntityId); - } + public string AccountLegalEntityPublicHashedId { get; set; } public static string GetId(string employerAccountId, string accountLegalEntityPublicHashedId) { return string.Format(IdFormat, employerAccountId, accountLegalEntityPublicHashedId); } public IList
OtherLocations { get; set; } = new List
(); - public string AccountLegalEntityPublicHashedId { get; set; } + } } diff --git a/src/Shared/Recruit.Vacancies.Client/Domain/Repositories/IEmployerProfileRepository.cs b/src/Shared/Recruit.Vacancies.Client/Domain/Repositories/IEmployerProfileRepository.cs index 029470dd8a..454252dee0 100644 --- a/src/Shared/Recruit.Vacancies.Client/Domain/Repositories/IEmployerProfileRepository.cs +++ b/src/Shared/Recruit.Vacancies.Client/Domain/Repositories/IEmployerProfileRepository.cs @@ -8,7 +8,7 @@ public interface IEmployerProfileRepository { Task CreateAsync(EmployerProfile profile); Task> GetEmployerProfilesForEmployerAsync(string employerAccountId); - Task GetAsync(string employerAccountId, long legalEntityId); + Task GetAsync(string employerAccountId, string accountLegalEntityPublicHashedId); Task UpdateAsync(EmployerProfile profile); } } \ No newline at end of file diff --git a/src/Shared/Recruit.Vacancies.Client/Infrastructure/Client/IJobsVacancyClient.cs b/src/Shared/Recruit.Vacancies.Client/Infrastructure/Client/IJobsVacancyClient.cs index 4e12827a6f..d7999bfb44 100644 --- a/src/Shared/Recruit.Vacancies.Client/Infrastructure/Client/IJobsVacancyClient.cs +++ b/src/Shared/Recruit.Vacancies.Client/Infrastructure/Client/IJobsVacancyClient.cs @@ -20,7 +20,7 @@ public interface IJobsVacancyClient Task PerformRulesCheckAsync(Guid reviewId); Task WithdrawApplicationAsync(long vacancyReference, Guid candidateId); Task HardDeleteApplicationReviewsForCandidate(Guid candidateId); - Task RefreshEmployerProfiles(string employerAccountId, IEnumerable legalEntities); + Task RefreshEmployerProfiles(string employerAccountId, IEnumerable accountLegalEntityPublicHashedIds); Task UpdateUserAccountAsync(string idamsUserId); } } \ No newline at end of file diff --git a/src/Shared/Recruit.Vacancies.Client/Infrastructure/Client/IRecruitVacancyClient.cs b/src/Shared/Recruit.Vacancies.Client/Infrastructure/Client/IRecruitVacancyClient.cs index 7b154a9763..ba850c410a 100644 --- a/src/Shared/Recruit.Vacancies.Client/Infrastructure/Client/IRecruitVacancyClient.cs +++ b/src/Shared/Recruit.Vacancies.Client/Infrastructure/Client/IRecruitVacancyClient.cs @@ -27,7 +27,7 @@ public interface IRecruitVacancyClient Task CloneVacancyAsync(Guid vacancyId, VacancyUser user, SourceOrigin sourceOrigin, DateTime startDate, DateTime closingDate); Task GetEmployerNameAsync(Vacancy vacancy); Task GetEmployerDescriptionAsync(Vacancy vacancy); - Task GetEmployerProfileAsync(string employerAccountId, long legalEntityId); + Task GetEmployerProfileAsync(string employerAccountId, string accountLegalEntityPublicHashedId); Task UpdateEmployerProfileAsync(EmployerProfile employerProfile, VacancyUser user); Task GetVacancyAnalyticsSummaryAsync(long vacancyReference); Task GetUsersDetailsAsync(string userId); diff --git a/src/Shared/Recruit.Vacancies.Client/Infrastructure/Client/VacancyClient.cs b/src/Shared/Recruit.Vacancies.Client/Infrastructure/Client/VacancyClient.cs index 1ff780c466..c4e3982e22 100644 --- a/src/Shared/Recruit.Vacancies.Client/Infrastructure/Client/VacancyClient.cs +++ b/src/Shared/Recruit.Vacancies.Client/Infrastructure/Client/VacancyClient.cs @@ -286,9 +286,9 @@ public Task SetApplicationReviewUnsuccessful(Guid applicationReviewId, string ca return _messaging.SendCommandAsync(command); } - public Task GetEmployerProfileAsync(string employerAccountId, long legalEntityId) + public Task GetEmployerProfileAsync(string employerAccountId, string accountLegalEntityPublicHashedId) { - return _employerProfileRepository.GetAsync(employerAccountId, legalEntityId); + return _employerProfileRepository.GetAsync(employerAccountId, accountLegalEntityPublicHashedId); } public Task UpdateEmployerProfileAsync(EmployerProfile employerProfile, VacancyUser user) @@ -422,12 +422,12 @@ public Task GetCurrentReferredVacancyReviewAsync(long vacancyRefe return _vacancyReviewQuery.GetCurrentReferredVacancyReviewAsync(vacancyReference); } - public Task RefreshEmployerProfiles(string employerAccountId, IEnumerable legalEntityIds) + public Task RefreshEmployerProfiles(string employerAccountId, IEnumerable accountLegalEntityPublicHashedIds) { return _messaging.SendCommandAsync(new RefreshEmployerProfilesCommand { EmployerAccountId = employerAccountId, - LegalEntityIds = legalEntityIds + AccountLegalEntityPublicHashedIds = accountLegalEntityPublicHashedIds }); } public Task GetUsersDetailsAsync(string userId) diff --git a/src/Shared/Recruit.Vacancies.Client/Infrastructure/Repositories/MongoDbEmployerProfileRepository.cs b/src/Shared/Recruit.Vacancies.Client/Infrastructure/Repositories/MongoDbEmployerProfileRepository.cs index 1797c03654..de4483c9bc 100644 --- a/src/Shared/Recruit.Vacancies.Client/Infrastructure/Repositories/MongoDbEmployerProfileRepository.cs +++ b/src/Shared/Recruit.Vacancies.Client/Infrastructure/Repositories/MongoDbEmployerProfileRepository.cs @@ -25,10 +25,10 @@ await RetryPolicy.ExecuteAsync(_ => new Context(nameof(CreateAsync))); } - public async Task GetAsync(string employerAccountId, long legalEntityId) + public async Task GetAsync(string employerAccountId, string accountLegalEntityPublicHashedId) { var builder = Builders.Filter; - var filter = builder.Eq(x => x.Id, EmployerProfile.GetId(employerAccountId, legalEntityId)); + var filter = builder.Eq(x => x.Id, EmployerProfile.GetId(employerAccountId, accountLegalEntityPublicHashedId)); var collection = GetCollection(); @@ -56,7 +56,6 @@ public Task UpdateAsync(EmployerProfile profile) { var builder = Builders.Filter; var filter = builder.Eq(x => x.EmployerAccountId, profile.EmployerAccountId) & - builder.Eq(x => x.LegalEntityId, profile.LegalEntityId) & builder.Eq(x => x.AccountLegalEntityPublicHashedId, profile.AccountLegalEntityPublicHashedId); var collection = GetCollection(); diff --git a/src/Shared/UnitTests/Shared.Web/Services/LegalEntityAgreementServiceTests.cs b/src/Shared/UnitTests/Shared.Web/Services/LegalEntityAgreementServiceTests.cs index a31cc7d88d..5a5090b36f 100644 --- a/src/Shared/UnitTests/Shared.Web/Services/LegalEntityAgreementServiceTests.cs +++ b/src/Shared/UnitTests/Shared.Web/Services/LegalEntityAgreementServiceTests.cs @@ -13,16 +13,16 @@ namespace Esfa.Recruit.Vacancies.Client.UnitTests.Shared.Web.Services public class LegalEntityAgreementServiceTests { const string EmployerAccountId = "ABCDEF"; - const long LegalEntityId = 1234; + const string AccountLegalEntityPublicHashedId = "XYZPQR"; private Mock _clientMock; [Fact] public async Task HasLegalEntityAgreementAsync_ShouldReturnFalseIfNoMatchingLegalEntity() { - var sut = GetLegalEntityAgreementService(EmployerAccountId, 5678, true, 5678, true); + var sut = GetLegalEntityAgreementService(EmployerAccountId, AccountLegalEntityPublicHashedId, true, AccountLegalEntityPublicHashedId, true); - var result = await sut.HasLegalEntityAgreementAsync(EmployerAccountId, LegalEntityId); + var result = await sut.HasLegalEntityAgreementAsync(EmployerAccountId, AccountLegalEntityPublicHashedId); result.Should().BeFalse(); _clientMock.Verify(c => c.GetEmployerLegalEntitiesAsync(EmployerAccountId), Times.Never); @@ -31,9 +31,9 @@ public async Task HasLegalEntityAgreementAsync_ShouldReturnFalseIfNoMatchingLega [Fact] public async Task HasLegalEntityAgreementAsync_ShouldNotCheckEmployerServiceWhenHasAgreement() { - var sut = GetLegalEntityAgreementService(EmployerAccountId, LegalEntityId, true, LegalEntityId, true); + var sut = GetLegalEntityAgreementService(EmployerAccountId, AccountLegalEntityPublicHashedId, true, AccountLegalEntityPublicHashedId, true); - var result = await sut.HasLegalEntityAgreementAsync(EmployerAccountId, LegalEntityId); + var result = await sut.HasLegalEntityAgreementAsync(EmployerAccountId, AccountLegalEntityPublicHashedId); result.Should().BeTrue(); _clientMock.Verify(c => c.GetEmployerLegalEntitiesAsync(EmployerAccountId), Times.Never); @@ -42,9 +42,9 @@ public async Task HasLegalEntityAgreementAsync_ShouldNotCheckEmployerServiceWhen [Fact] public async Task HasLegalEntityAgreementAsync_ShouldCheckEmployerServiceWhenHasNoAgreement() { - var sut = GetLegalEntityAgreementService(EmployerAccountId, LegalEntityId, false, LegalEntityId, true); + var sut = GetLegalEntityAgreementService(EmployerAccountId, AccountLegalEntityPublicHashedId, false, AccountLegalEntityPublicHashedId, true); - var result = await sut.HasLegalEntityAgreementAsync(EmployerAccountId, LegalEntityId); + var result = await sut.HasLegalEntityAgreementAsync(EmployerAccountId, AccountLegalEntityPublicHashedId); result.Should().BeTrue(); _clientMock.Verify(c => c.GetEmployerLegalEntitiesAsync(EmployerAccountId), Times.Once); @@ -54,9 +54,9 @@ public async Task HasLegalEntityAgreementAsync_ShouldCheckEmployerServiceWhenHas [Fact] public async Task HasLegalEntityAgreementAsync_ShouldReturnFalseWhenEmployerServiceLegalEntityHasNoAgreement() { - var sut = GetLegalEntityAgreementService(EmployerAccountId, LegalEntityId, false, LegalEntityId, false); + var sut = GetLegalEntityAgreementService(EmployerAccountId, AccountLegalEntityPublicHashedId, false, AccountLegalEntityPublicHashedId, false); - var result = await sut.HasLegalEntityAgreementAsync(EmployerAccountId, LegalEntityId); + var result = await sut.HasLegalEntityAgreementAsync(EmployerAccountId, AccountLegalEntityPublicHashedId); result.Should().BeFalse(); _clientMock.Verify(c => c.GetEmployerLegalEntitiesAsync(EmployerAccountId), Times.Once); @@ -66,16 +66,16 @@ public async Task HasLegalEntityAgreementAsync_ShouldReturnFalseWhenEmployerServ [Fact] public async Task HasLegalEntityAgreementAsync_ShouldReturnFalseWhenEmployerServiceCantLocateLegalEntity() { - var sut = GetLegalEntityAgreementService(EmployerAccountId, LegalEntityId, false, 5678, true); + var sut = GetLegalEntityAgreementService(EmployerAccountId, AccountLegalEntityPublicHashedId, false, AccountLegalEntityPublicHashedId, true); - var result = await sut.HasLegalEntityAgreementAsync(EmployerAccountId, LegalEntityId); + var result = await sut.HasLegalEntityAgreementAsync(EmployerAccountId, AccountLegalEntityPublicHashedId); result.Should().BeFalse(); _clientMock.Verify(c => c.GetEmployerLegalEntitiesAsync(EmployerAccountId), Times.Once); _clientMock.Verify(c => c.SetupEmployerAsync(EmployerAccountId), Times.Never); } - private LegalEntityAgreementService GetLegalEntityAgreementService(string employerAccountId, long legalEntityId, bool hasLegalEntityAgreement, long employerServiceLegalEntityId, bool employerServiceHasLegalEntityAgreement) + private LegalEntityAgreementService GetLegalEntityAgreementService(string employerAccountId, string accountLegalEntityPublicHashedId, bool hasLegalEntityAgreement, string employerServiceAccountLegalEntityPublicHashedId, bool employerServiceHasLegalEntityAgreement) { _clientMock = new Mock(); _clientMock.Setup(c => c.GetEditVacancyInfoAsync(employerAccountId)).Returns(Task.FromResult( @@ -83,7 +83,11 @@ private LegalEntityAgreementService GetLegalEntityAgreementService(string employ { LegalEntities = new List { - new LegalEntity{LegalEntityId = legalEntityId, HasLegalEntityAgreement = hasLegalEntityAgreement} + new LegalEntity + { + AccountLegalEntityPublicHashedId = AccountLegalEntityPublicHashedId, + HasLegalEntityAgreement = hasLegalEntityAgreement + } } })); @@ -92,8 +96,8 @@ private LegalEntityAgreementService GetLegalEntityAgreementService(string employ { new LegalEntity { - LegalEntityId = employerServiceLegalEntityId, - HasLegalEntityAgreement = employerServiceHasLegalEntityAgreement + AccountLegalEntityPublicHashedId = accountLegalEntityPublicHashedId, + HasLegalEntityAgreement = employerServiceHasLegalEntityAgreement } } .AsEnumerable())); diff --git a/src/Shared/UnitTests/Vacancies.Client/Application/Services/EmployerService/GetEmployerDescriptionTests.cs b/src/Shared/UnitTests/Vacancies.Client/Application/Services/EmployerService/GetEmployerDescriptionTests.cs index 768d93338d..308e488a4a 100644 --- a/src/Shared/UnitTests/Vacancies.Client/Application/Services/EmployerService/GetEmployerDescriptionTests.cs +++ b/src/Shared/UnitTests/Vacancies.Client/Application/Services/EmployerService/GetEmployerDescriptionTests.cs @@ -5,7 +5,7 @@ using Moq; using Xunit; -namespace Esfa.Recruit.UnitTests.Vacancies.Client.Application.Services.EmployerService +namespace Esfa.Recruit.Vacancies.Client.UnitTests.Vacancies.Client.Application.Services.EmployerService { public class GetEmployerDescriptionTests { @@ -27,7 +27,7 @@ public async Task GetEmployerDescriptionAsync_ShouldReturnEmployerProfileAboutOr AboutOrganisation = employerProfileAboutOrganisation }; - _mockEmployerProfileRepository.Setup(pr => pr.GetAsync(It.IsAny(), It.IsAny())).ReturnsAsync(profile); + _mockEmployerProfileRepository.Setup(pr => pr.GetAsync(It.IsAny(), It.IsAny())).ReturnsAsync(profile); var sut = GetSut(); diff --git a/src/Shared/UnitTests/Vacancies.Client/Application/Services/EmployerService/GetEmployerNameTests.cs b/src/Shared/UnitTests/Vacancies.Client/Application/Services/EmployerService/GetEmployerNameTests.cs index 525813a326..850ca83fc4 100644 --- a/src/Shared/UnitTests/Vacancies.Client/Application/Services/EmployerService/GetEmployerNameTests.cs +++ b/src/Shared/UnitTests/Vacancies.Client/Application/Services/EmployerService/GetEmployerNameTests.cs @@ -75,7 +75,7 @@ public async Task GetEmployerNameAsync_ShouldReturnTradingName(VacancyStatus sta TradingName = tradingName }; - _mockEmployerProfileRepository.Setup(pr => pr.GetAsync(It.IsAny(), It.IsAny())).ReturnsAsync(profile); + _mockEmployerProfileRepository.Setup(pr => pr.GetAsync(It.IsAny(), It.IsAny())).ReturnsAsync(profile); var sut = GetSut(); From 2a9ca3e447fef13dd82fff7fce1c15a8cfb001e5 Mon Sep 17 00:00:00 2001 From: Shoma Gujjar Date: Mon, 3 Aug 2020 12:17:02 +0100 Subject: [PATCH 03/12] CON-1186-remove legal entity --- .../Controllers/Part1/EmployerController.cs | 8 ++++---- .../Orchestrators/Part1/EmployerOrchestrator.cs | 2 +- .../ViewModels/Part1/Employer/EmployerEditModel.cs | 2 +- .../ViewModels/Part1/Employer/EmployerViewModel.cs | 9 ++++----- .../Services/LegalEntityAgreementServiceTests.cs | 11 ++++++----- .../RefreshEmployerProfilesCommandHandler.cs | 2 +- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/Employer/Employer.Web/Controllers/Part1/EmployerController.cs b/src/Employer/Employer.Web/Controllers/Part1/EmployerController.cs index b2822d51ae..2e4f5f5be7 100644 --- a/src/Employer/Employer.Web/Controllers/Part1/EmployerController.cs +++ b/src/Employer/Employer.Web/Controllers/Part1/EmployerController.cs @@ -33,7 +33,7 @@ public async Task Employer(VacancyRouteModel vrm, [FromQuery]stri } else { - vm.AccountLegalEntityPublicHashedId = info.AccountLegalEntityPublicHashedId; + vm.SelectedOrganisationId = info.AccountLegalEntityPublicHashedId; } if (vm.HasOnlyOneOrganisation) @@ -54,7 +54,7 @@ public async Task Employer(EmployerEditModel m, [FromQuery] bool { //something went wrong, the matching cookie was not found //Redirect the user with validation error to allow them to continue - ModelState.AddModelError(nameof(EmployerEditModel.AccountLegalEntityPublicHashedId), + ModelState.AddModelError(nameof(EmployerEditModel.SelectedOrganisationId), ValidationMessages.EmployerSelectionValidationMessages.EmployerSelectionRequired); } @@ -67,9 +67,9 @@ public async Task Employer(EmployerEditModel m, [FromQuery] bool return View(vm); } - if (info.AccountLegalEntityPublicHashedId != m.AccountLegalEntityPublicHashedId) + if (info.AccountLegalEntityPublicHashedId != m.SelectedOrganisationId) { - info.AccountLegalEntityPublicHashedId = m.AccountLegalEntityPublicHashedId; + info.AccountLegalEntityPublicHashedId = m.SelectedOrganisationId; info.HasLegalEntityChanged = true; info.EmployerIdentityOption = null; info.NewTradingName = null; diff --git a/src/Employer/Employer.Web/Orchestrators/Part1/EmployerOrchestrator.cs b/src/Employer/Employer.Web/Orchestrators/Part1/EmployerOrchestrator.cs index 191d546a1d..15b70946fd 100644 --- a/src/Employer/Employer.Web/Orchestrators/Part1/EmployerOrchestrator.cs +++ b/src/Employer/Employer.Web/Orchestrators/Part1/EmployerOrchestrator.cs @@ -51,7 +51,7 @@ public async Task GetEmployerViewModelAsync(VacancyRouteModel TotalNumberOfLegalEntities = legalEntities.Count(), PageInfo = Utility.GetPartOnePageInfo(vacancy), SearchTerm = searchTerm, - AccountLegalEntityPublicHashedId = vacancy.AccountLegalEntityPublicHashedId + SelectedOrganisationId = vacancy.AccountLegalEntityPublicHashedId }; //if (vacancy.LegalEntityId != 0 && (selectedLegalEntityId.HasValue == false || selectedLegalEntityId == 0)) diff --git a/src/Employer/Employer.Web/ViewModels/Part1/Employer/EmployerEditModel.cs b/src/Employer/Employer.Web/ViewModels/Part1/Employer/EmployerEditModel.cs index 80d93f9628..568ed94dc2 100644 --- a/src/Employer/Employer.Web/ViewModels/Part1/Employer/EmployerEditModel.cs +++ b/src/Employer/Employer.Web/ViewModels/Part1/Employer/EmployerEditModel.cs @@ -6,7 +6,7 @@ namespace Esfa.Recruit.Employer.Web.ViewModels.Part1.Employer public class EmployerEditModel : VacancyRouteModel { [Required(ErrorMessage = ValidationMessages.EmployerSelectionValidationMessages.EmployerSelectionRequired)] - public string AccountLegalEntityPublicHashedId { get; set; } + public string SelectedOrganisationId { get; set; } public string SearchTerm { get; set; } public int Page { get; set; } } diff --git a/src/Employer/Employer.Web/ViewModels/Part1/Employer/EmployerViewModel.cs b/src/Employer/Employer.Web/ViewModels/Part1/Employer/EmployerViewModel.cs index eb0cf2cde3..c2e05f9037 100644 --- a/src/Employer/Employer.Web/ViewModels/Part1/Employer/EmployerViewModel.cs +++ b/src/Employer/Employer.Web/ViewModels/Part1/Employer/EmployerViewModel.cs @@ -17,10 +17,9 @@ public class EmployerViewModel : VacancyRouteModel public PartOnePageInfoViewModel PageInfo { get; internal set; } public PagerViewModel Pager { get; internal set; } - public string AccountLegalEntityPublicHashedId { get; set; } public IList OrderedFieldNames => new List { - nameof(AccountLegalEntityPublicHashedId) + nameof(SelectedOrganisationId ) }; public string SelectedOrganisationId { get; internal set; } @@ -38,13 +37,13 @@ public class EmployerViewModel : VacancyRouteModel public int TotalNumberOfLegalEntities { get; internal set; } public bool IsPreviouslySelectedLegalEntityStillValid { get; internal set; } - public bool HasPreviouslyPersistedLegalEntity => !string.IsNullOrEmpty(AccountLegalEntityPublicHashedId); + public bool HasPreviouslyPersistedLegalEntity => !string.IsNullOrEmpty(SelectedOrganisationId); public bool IsSelectedOrganisationInPagedOrganisations => IsPreviouslySelectedLegalEntityStillValid && HasPreviouslyPersistedLegalEntity - && Organisations.Any(org => org.Id == AccountLegalEntityPublicHashedId); + && Organisations.Any(org => org.Id == SelectedOrganisationId); - public bool CanOutputHiddenSelectedOrganisationIdField => !string.IsNullOrEmpty(AccountLegalEntityPublicHashedId) && IsSelectedOrganisationInPagedOrganisations == false; + public bool CanOutputHiddenSelectedOrganisationIdField => !string.IsNullOrEmpty(SelectedOrganisationId) && IsSelectedOrganisationInPagedOrganisations == false; } public class OrganisationViewModel diff --git a/src/Employer/UnitTests/Employer.Web/Services/LegalEntityAgreementServiceTests.cs b/src/Employer/UnitTests/Employer.Web/Services/LegalEntityAgreementServiceTests.cs index d6a163a523..480fcccfc2 100644 --- a/src/Employer/UnitTests/Employer.Web/Services/LegalEntityAgreementServiceTests.cs +++ b/src/Employer/UnitTests/Employer.Web/Services/LegalEntityAgreementServiceTests.cs @@ -14,6 +14,7 @@ public class LegalEntityAgreementServiceTests { const string EmployerAccountId = "ABCDEF"; const long LegalEntityId = 1234; + const string AccountLegalEntityPublicHashedId = "ABCDEF"; private Mock _clientMock; @@ -22,7 +23,7 @@ public void HasLegalEntityAgreementAsync_ShouldReturnFalseIfNoMatchingLegalEntit { var sut = GetLegalEntityAgreementService(EmployerAccountId, 5678, true, 5678, true); - var result = sut.HasLegalEntityAgreementAsync(EmployerAccountId, LegalEntityId).Result; + var result = sut.HasLegalEntityAgreementAsync(EmployerAccountId, AccountLegalEntityPublicHashedId).Result; result.Should().BeFalse(); _clientMock.Verify(c => c.GetEmployerLegalEntitiesAsync(EmployerAccountId), Times.Never); @@ -33,7 +34,7 @@ public void HasLegalEntityAgreementAsync_ShouldNotCheckEmployerServiceWhenHasAgr { var sut = GetLegalEntityAgreementService(EmployerAccountId, LegalEntityId, true, LegalEntityId, true); - var result = sut.HasLegalEntityAgreementAsync(EmployerAccountId, LegalEntityId).Result; + var result = sut.HasLegalEntityAgreementAsync(EmployerAccountId, AccountLegalEntityPublicHashedId).Result; result.Should().BeTrue(); _clientMock.Verify(c => c.GetEmployerLegalEntitiesAsync(EmployerAccountId), Times.Never); @@ -43,7 +44,7 @@ [Fact] public void HasLegalEntityAgreementAsync_ShouldCheckEmployerServiceWhenHa { var sut = GetLegalEntityAgreementService(EmployerAccountId, LegalEntityId, false, LegalEntityId, true); - var result = sut.HasLegalEntityAgreementAsync(EmployerAccountId, LegalEntityId).Result; + var result = sut.HasLegalEntityAgreementAsync(EmployerAccountId, AccountLegalEntityPublicHashedId).Result; result.Should().BeTrue(); _clientMock.Verify(c => c.GetEmployerLegalEntitiesAsync(EmployerAccountId), Times.Once); @@ -54,7 +55,7 @@ [Fact] public void HasLegalEntityAgreementAsync_ShouldReturnFalseWhenEmployerSer { var sut = GetLegalEntityAgreementService(EmployerAccountId, LegalEntityId, false, LegalEntityId, false); - var result = sut.HasLegalEntityAgreementAsync(EmployerAccountId, LegalEntityId).Result; + var result = sut.HasLegalEntityAgreementAsync(EmployerAccountId, AccountLegalEntityPublicHashedId).Result; result.Should().BeFalse(); _clientMock.Verify(c => c.GetEmployerLegalEntitiesAsync(EmployerAccountId), Times.Once); @@ -66,7 +67,7 @@ public void HasLegalEntityAgreementAsync_ShouldReturnFalseWhenEmployerServiceCan { var sut = GetLegalEntityAgreementService(EmployerAccountId, LegalEntityId, false, 5678, true); - var result = sut.HasLegalEntityAgreementAsync(EmployerAccountId, LegalEntityId).Result; + var result = sut.HasLegalEntityAgreementAsync(EmployerAccountId, AccountLegalEntityPublicHashedId).Result; result.Should().BeFalse(); _clientMock.Verify(c => c.GetEmployerLegalEntitiesAsync(EmployerAccountId), Times.Once); diff --git a/src/Shared/Recruit.Vacancies.Client/Application/CommandHandlers/RefreshEmployerProfilesCommandHandler.cs b/src/Shared/Recruit.Vacancies.Client/Application/CommandHandlers/RefreshEmployerProfilesCommandHandler.cs index b412a2a7d4..6bf3220f02 100644 --- a/src/Shared/Recruit.Vacancies.Client/Application/CommandHandlers/RefreshEmployerProfilesCommandHandler.cs +++ b/src/Shared/Recruit.Vacancies.Client/Application/CommandHandlers/RefreshEmployerProfilesCommandHandler.cs @@ -45,7 +45,7 @@ public async Task Handle(RefreshEmployerProfilesCommand message, CancellationTok var selectedOrganisation = editVacancyInfo.LegalEntities.Single(l => l.AccountLegalEntityPublicHashedId == accountLegalEntityPublicHashedId); if (!profiles.Any(x => x.AccountLegalEntityPublicHashedId == accountLegalEntityPublicHashedId)) - { + { var currentTime = _time.Now; // Create new profile From 7c6a26f4588e6c567cbde3e5dc119a0b9e9771a2 Mon Sep 17 00:00:00 2001 From: Shoma Gujjar Date: Mon, 3 Aug 2020 12:33:56 +0100 Subject: [PATCH 04/12] CON-1186-use employerhashedid --- .../Part1/EmployerOrchestrator.cs | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Employer/Employer.Web/Orchestrators/Part1/EmployerOrchestrator.cs b/src/Employer/Employer.Web/Orchestrators/Part1/EmployerOrchestrator.cs index 15b70946fd..ca1331bb58 100644 --- a/src/Employer/Employer.Web/Orchestrators/Part1/EmployerOrchestrator.cs +++ b/src/Employer/Employer.Web/Orchestrators/Part1/EmployerOrchestrator.cs @@ -33,7 +33,7 @@ public EmployerOrchestrator( _logger = logger; } - public async Task GetEmployerViewModelAsync(VacancyRouteModel vrm, string searchTerm, int? requestedPageNo, string accountLegalEntityPublicHashedId) + public async Task GetEmployerViewModelAsync(VacancyRouteModel vrm, string searchTerm, int? requestedPageNo, string selectedAccountLegalEntityPublicHashedId) { const int NotFoundIndex = -1; var setPage = requestedPageNo.HasValue ? requestedPageNo.Value : 1; @@ -54,12 +54,12 @@ public async Task GetEmployerViewModelAsync(VacancyRouteModel SelectedOrganisationId = vacancy.AccountLegalEntityPublicHashedId }; - //if (vacancy.LegalEntityId != 0 && (selectedLegalEntityId.HasValue == false || selectedLegalEntityId == 0)) - //{ - // selectedLegalEntityId = vacancy.LegalEntityId; - //} + if (!string.IsNullOrEmpty(vacancy.AccountLegalEntityPublicHashedId) && string.IsNullOrEmpty(selectedAccountLegalEntityPublicHashedId)) + { + selectedAccountLegalEntityPublicHashedId = vacancy.AccountLegalEntityPublicHashedId; + } - vm.IsPreviouslySelectedLegalEntityStillValid = !string.IsNullOrEmpty(accountLegalEntityPublicHashedId) && legalEntities.Any(le => le.Id == accountLegalEntityPublicHashedId); + vm.IsPreviouslySelectedLegalEntityStillValid = !string.IsNullOrEmpty(selectedAccountLegalEntityPublicHashedId) && legalEntities.Any(le => le.Id == selectedAccountLegalEntityPublicHashedId); var filteredLegalEntities = legalEntities .Where(le => string.IsNullOrEmpty(searchTerm) || le.Name.Contains(searchTerm, StringComparison.OrdinalIgnoreCase)) @@ -69,8 +69,8 @@ public async Task GetEmployerViewModelAsync(VacancyRouteModel var filteredLegalEntitiesTotal = filteredLegalEntities.Count(); var totalNumberOfPages = PagingHelper.GetTotalNoOfPages(MaxLegalEntitiesPerPage, filteredLegalEntitiesTotal); - var indexOfSelectedLegalEntity = !string.IsNullOrEmpty(accountLegalEntityPublicHashedId) - ? filteredLegalEntities.FindIndex(le => le.Id == accountLegalEntityPublicHashedId) + 1 + var indexOfSelectedLegalEntity = !string.IsNullOrEmpty(selectedAccountLegalEntityPublicHashedId) + ? filteredLegalEntities.FindIndex(le => le.Id == selectedAccountLegalEntityPublicHashedId) + 1 : NotFoundIndex; setPage = GetPageNo(requestedPageNo, setPage, totalNumberOfPages, indexOfSelectedLegalEntity); @@ -85,10 +85,10 @@ public async Task GetEmployerViewModelAsync(VacancyRouteModel AccountLegalEntityPublicHashedId = vacancy.AccountLegalEntityPublicHashedId }; - //if (vm.VacancyEmployerInfoModel.AccountLegalEntityPublicHashedId == null && vm.HasOnlyOneOrganisation) - //{ - // vm.VacancyEmployerInfoModel.AccountLegalEntityPublicHashedId = vm.Organisations.First().Id; - //} + if (vm.VacancyEmployerInfoModel.AccountLegalEntityPublicHashedId == null && vm.HasOnlyOneOrganisation) + { + vm.VacancyEmployerInfoModel.AccountLegalEntityPublicHashedId = vm.Organisations.First().Id; + } if (vacancy.EmployerNameOption.HasValue) { From 1d8ec5e2f03cb3f933ad4e9860af160b3784882d Mon Sep 17 00:00:00 2001 From: Shoma Gujjar Date: Mon, 3 Aug 2020 13:28:31 +0100 Subject: [PATCH 05/12] CON-1186-save vacancy --- .../Orchestrators/LegalEntityAgreementOrchestrator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Employer/Employer.Web/Orchestrators/LegalEntityAgreementOrchestrator.cs b/src/Employer/Employer.Web/Orchestrators/LegalEntityAgreementOrchestrator.cs index 5a423987df..59fdbeafef 100644 --- a/src/Employer/Employer.Web/Orchestrators/LegalEntityAgreementOrchestrator.cs +++ b/src/Employer/Employer.Web/Orchestrators/LegalEntityAgreementOrchestrator.cs @@ -31,7 +31,7 @@ public async Task GetLegalEntityAgreement Utility.GetAuthorisedVacancyForEditAsync( _client, _vacancyClient, vrm, RouteNames.LegalEntityAgreement_SoftStop_Get); - var accountLegalEntityPublicHashedId = string.IsNullOrEmpty(selectedAccountLegalEntityPublicHashedId) ? selectedAccountLegalEntityPublicHashedId : vacancy.AccountLegalEntityPublicHashedId; + var accountLegalEntityPublicHashedId = !string.IsNullOrEmpty(selectedAccountLegalEntityPublicHashedId) ? selectedAccountLegalEntityPublicHashedId : vacancy.AccountLegalEntityPublicHashedId; LegalEntity legalEntity = await _legalEntityAgreementService.GetLegalEntityAsync(vrm.EmployerAccountId, accountLegalEntityPublicHashedId); From 65e5d803c4b559a2e88e32324e9ba818d2f82066 Mon Sep 17 00:00:00 2001 From: Shoma Gujjar Date: Mon, 3 Aug 2020 14:07:50 +0100 Subject: [PATCH 06/12] CON-1186-fix tests --- .../Services/LegalEntityAgreementServiceTests.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/Employer/UnitTests/Employer.Web/Services/LegalEntityAgreementServiceTests.cs b/src/Employer/UnitTests/Employer.Web/Services/LegalEntityAgreementServiceTests.cs index 480fcccfc2..88f9ca9246 100644 --- a/src/Employer/UnitTests/Employer.Web/Services/LegalEntityAgreementServiceTests.cs +++ b/src/Employer/UnitTests/Employer.Web/Services/LegalEntityAgreementServiceTests.cs @@ -40,7 +40,8 @@ public void HasLegalEntityAgreementAsync_ShouldNotCheckEmployerServiceWhenHasAgr _clientMock.Verify(c => c.GetEmployerLegalEntitiesAsync(EmployerAccountId), Times.Never); } - [Fact] public void HasLegalEntityAgreementAsync_ShouldCheckEmployerServiceWhenHasNoAgreement() + [Fact] + public void HasLegalEntityAgreementAsync_ShouldCheckEmployerServiceWhenHasNoAgreement() { var sut = GetLegalEntityAgreementService(EmployerAccountId, LegalEntityId, false, LegalEntityId, true); @@ -51,7 +52,8 @@ [Fact] public void HasLegalEntityAgreementAsync_ShouldCheckEmployerServiceWhenHa _clientMock.Verify(c => c.SetupEmployerAsync(EmployerAccountId), Times.Once); } - [Fact] public void HasLegalEntityAgreementAsync_ShouldReturnFalseWhenEmployerServiceLegalEntityHasNoAgreement() + [Fact] + public void HasLegalEntityAgreementAsync_ShouldReturnFalseWhenEmployerServiceLegalEntityHasNoAgreement() { var sut = GetLegalEntityAgreementService(EmployerAccountId, LegalEntityId, false, LegalEntityId, false); @@ -82,7 +84,11 @@ private LegalEntityAgreementService GetLegalEntityAgreementService(string employ { LegalEntities = new List { - new LegalEntity{LegalEntityId = legalEntityId, HasLegalEntityAgreement = hasLegalEntityAgreement} + new LegalEntity{ + LegalEntityId = legalEntityId, + HasLegalEntityAgreement = hasLegalEntityAgreement, + AccountLegalEntityPublicHashedId = AccountLegalEntityPublicHashedId + } } })); @@ -91,8 +97,8 @@ private LegalEntityAgreementService GetLegalEntityAgreementService(string employ { new LegalEntity { - LegalEntityId = employerServiceLegalEntityId, - HasLegalEntityAgreement = employerServiceHasLegalEntityAgreement + LegalEntityId = employerServiceLegalEntityId, + HasLegalEntityAgreement = employerServiceHasLegalEntityAgreement } } .AsEnumerable())); From 9a5cf7d95cc079748f57f406b06ac5baa5eeb71d Mon Sep 17 00:00:00 2001 From: Shoma Gujjar Date: Mon, 3 Aug 2020 14:28:40 +0100 Subject: [PATCH 07/12] CON-1186-fix unit tests. --- .../Services/LegalEntityAgreementServiceTests.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Employer/UnitTests/Employer.Web/Services/LegalEntityAgreementServiceTests.cs b/src/Employer/UnitTests/Employer.Web/Services/LegalEntityAgreementServiceTests.cs index 88f9ca9246..b7f0fffcb6 100644 --- a/src/Employer/UnitTests/Employer.Web/Services/LegalEntityAgreementServiceTests.cs +++ b/src/Employer/UnitTests/Employer.Web/Services/LegalEntityAgreementServiceTests.cs @@ -21,7 +21,7 @@ public class LegalEntityAgreementServiceTests [Fact] public void HasLegalEntityAgreementAsync_ShouldReturnFalseIfNoMatchingLegalEntity() { - var sut = GetLegalEntityAgreementService(EmployerAccountId, 5678, true, 5678, true); + var sut = GetLegalEntityAgreementService(EmployerAccountId, 5678, true, 5678, true, "5678"); var result = sut.HasLegalEntityAgreementAsync(EmployerAccountId, AccountLegalEntityPublicHashedId).Result; @@ -32,7 +32,7 @@ public void HasLegalEntityAgreementAsync_ShouldReturnFalseIfNoMatchingLegalEntit [Fact] public void HasLegalEntityAgreementAsync_ShouldNotCheckEmployerServiceWhenHasAgreement() { - var sut = GetLegalEntityAgreementService(EmployerAccountId, LegalEntityId, true, LegalEntityId, true); + var sut = GetLegalEntityAgreementService(EmployerAccountId, LegalEntityId, true, LegalEntityId, true, AccountLegalEntityPublicHashedId); var result = sut.HasLegalEntityAgreementAsync(EmployerAccountId, AccountLegalEntityPublicHashedId).Result; @@ -43,7 +43,7 @@ public void HasLegalEntityAgreementAsync_ShouldNotCheckEmployerServiceWhenHasAgr [Fact] public void HasLegalEntityAgreementAsync_ShouldCheckEmployerServiceWhenHasNoAgreement() { - var sut = GetLegalEntityAgreementService(EmployerAccountId, LegalEntityId, false, LegalEntityId, true); + var sut = GetLegalEntityAgreementService(EmployerAccountId, LegalEntityId, false, LegalEntityId, true, AccountLegalEntityPublicHashedId); var result = sut.HasLegalEntityAgreementAsync(EmployerAccountId, AccountLegalEntityPublicHashedId).Result; @@ -55,7 +55,7 @@ public void HasLegalEntityAgreementAsync_ShouldCheckEmployerServiceWhenHasNoAgre [Fact] public void HasLegalEntityAgreementAsync_ShouldReturnFalseWhenEmployerServiceLegalEntityHasNoAgreement() { - var sut = GetLegalEntityAgreementService(EmployerAccountId, LegalEntityId, false, LegalEntityId, false); + var sut = GetLegalEntityAgreementService(EmployerAccountId, LegalEntityId, false, LegalEntityId, false, AccountLegalEntityPublicHashedId); var result = sut.HasLegalEntityAgreementAsync(EmployerAccountId, AccountLegalEntityPublicHashedId).Result; @@ -67,7 +67,7 @@ public void HasLegalEntityAgreementAsync_ShouldReturnFalseWhenEmployerServiceLeg [Fact] public void HasLegalEntityAgreementAsync_ShouldReturnFalseWhenEmployerServiceCantLocateLegalEntity() { - var sut = GetLegalEntityAgreementService(EmployerAccountId, LegalEntityId, false, 5678, true); + var sut = GetLegalEntityAgreementService(EmployerAccountId, LegalEntityId, false, 5678, true, AccountLegalEntityPublicHashedId); var result = sut.HasLegalEntityAgreementAsync(EmployerAccountId, AccountLegalEntityPublicHashedId).Result; @@ -76,7 +76,9 @@ public void HasLegalEntityAgreementAsync_ShouldReturnFalseWhenEmployerServiceCan _clientMock.Verify(c => c.SetupEmployerAsync(EmployerAccountId), Times.Never); } - private LegalEntityAgreementService GetLegalEntityAgreementService(string employerAccountId, long legalEntityId, bool hasLegalEntityAgreement, long employerServiceLegalEntityId, bool employerServiceHasLegalEntityAgreement) + private LegalEntityAgreementService GetLegalEntityAgreementService(string employerAccountId, long legalEntityId, + bool hasLegalEntityAgreement, long employerServiceLegalEntityId, + bool employerServiceHasLegalEntityAgreement, string accountLegalEntityPublicHashedId) { _clientMock = new Mock(); _clientMock.Setup(c => c.GetEditVacancyInfoAsync(employerAccountId)).Returns(Task.FromResult( @@ -87,7 +89,7 @@ private LegalEntityAgreementService GetLegalEntityAgreementService(string employ new LegalEntity{ LegalEntityId = legalEntityId, HasLegalEntityAgreement = hasLegalEntityAgreement, - AccountLegalEntityPublicHashedId = AccountLegalEntityPublicHashedId + AccountLegalEntityPublicHashedId = accountLegalEntityPublicHashedId } } })); From e4b8e97365c0d6fb60b33d9cb02422b8a42d8858 Mon Sep 17 00:00:00 2001 From: Shoma Gujjar Date: Mon, 3 Aug 2020 15:12:30 +0100 Subject: [PATCH 08/12] CON-1186-fix tests. --- .../LegalEntityAgreementServiceTests.cs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Shared/UnitTests/Shared.Web/Services/LegalEntityAgreementServiceTests.cs b/src/Shared/UnitTests/Shared.Web/Services/LegalEntityAgreementServiceTests.cs index 5a5090b36f..4eea950f61 100644 --- a/src/Shared/UnitTests/Shared.Web/Services/LegalEntityAgreementServiceTests.cs +++ b/src/Shared/UnitTests/Shared.Web/Services/LegalEntityAgreementServiceTests.cs @@ -14,13 +14,13 @@ public class LegalEntityAgreementServiceTests { const string EmployerAccountId = "ABCDEF"; const string AccountLegalEntityPublicHashedId = "XYZPQR"; - + const long LegalEntityId = 1234; private Mock _clientMock; [Fact] public async Task HasLegalEntityAgreementAsync_ShouldReturnFalseIfNoMatchingLegalEntity() { - var sut = GetLegalEntityAgreementService(EmployerAccountId, AccountLegalEntityPublicHashedId, true, AccountLegalEntityPublicHashedId, true); + var sut = GetLegalEntityAgreementService(EmployerAccountId, 5678, true, 5678, true, "5678"); var result = await sut.HasLegalEntityAgreementAsync(EmployerAccountId, AccountLegalEntityPublicHashedId); @@ -31,7 +31,7 @@ public async Task HasLegalEntityAgreementAsync_ShouldReturnFalseIfNoMatchingLega [Fact] public async Task HasLegalEntityAgreementAsync_ShouldNotCheckEmployerServiceWhenHasAgreement() { - var sut = GetLegalEntityAgreementService(EmployerAccountId, AccountLegalEntityPublicHashedId, true, AccountLegalEntityPublicHashedId, true); + var sut = GetLegalEntityAgreementService(EmployerAccountId, LegalEntityId, true, LegalEntityId, true, AccountLegalEntityPublicHashedId); var result = await sut.HasLegalEntityAgreementAsync(EmployerAccountId, AccountLegalEntityPublicHashedId); @@ -42,7 +42,7 @@ public async Task HasLegalEntityAgreementAsync_ShouldNotCheckEmployerServiceWhen [Fact] public async Task HasLegalEntityAgreementAsync_ShouldCheckEmployerServiceWhenHasNoAgreement() { - var sut = GetLegalEntityAgreementService(EmployerAccountId, AccountLegalEntityPublicHashedId, false, AccountLegalEntityPublicHashedId, true); + var sut = GetLegalEntityAgreementService(EmployerAccountId, LegalEntityId, false, LegalEntityId, true, AccountLegalEntityPublicHashedId); var result = await sut.HasLegalEntityAgreementAsync(EmployerAccountId, AccountLegalEntityPublicHashedId); @@ -54,7 +54,7 @@ public async Task HasLegalEntityAgreementAsync_ShouldCheckEmployerServiceWhenHas [Fact] public async Task HasLegalEntityAgreementAsync_ShouldReturnFalseWhenEmployerServiceLegalEntityHasNoAgreement() { - var sut = GetLegalEntityAgreementService(EmployerAccountId, AccountLegalEntityPublicHashedId, false, AccountLegalEntityPublicHashedId, false); + var sut = GetLegalEntityAgreementService(EmployerAccountId, LegalEntityId, false, LegalEntityId, false, AccountLegalEntityPublicHashedId); var result = await sut.HasLegalEntityAgreementAsync(EmployerAccountId, AccountLegalEntityPublicHashedId); @@ -66,7 +66,7 @@ public async Task HasLegalEntityAgreementAsync_ShouldReturnFalseWhenEmployerServ [Fact] public async Task HasLegalEntityAgreementAsync_ShouldReturnFalseWhenEmployerServiceCantLocateLegalEntity() { - var sut = GetLegalEntityAgreementService(EmployerAccountId, AccountLegalEntityPublicHashedId, false, AccountLegalEntityPublicHashedId, true); + var sut = GetLegalEntityAgreementService(EmployerAccountId, LegalEntityId, false, 5678, true, AccountLegalEntityPublicHashedId); var result = await sut.HasLegalEntityAgreementAsync(EmployerAccountId, AccountLegalEntityPublicHashedId); @@ -75,7 +75,7 @@ public async Task HasLegalEntityAgreementAsync_ShouldReturnFalseWhenEmployerServ _clientMock.Verify(c => c.SetupEmployerAsync(EmployerAccountId), Times.Never); } - private LegalEntityAgreementService GetLegalEntityAgreementService(string employerAccountId, string accountLegalEntityPublicHashedId, bool hasLegalEntityAgreement, string employerServiceAccountLegalEntityPublicHashedId, bool employerServiceHasLegalEntityAgreement) + private LegalEntityAgreementService GetLegalEntityAgreementService(string employerAccountId, long legalEntityId, bool hasLegalEntityAgreement, long employerServiceLegalEntityId, bool employerServiceHasLegalEntityAgreement, string accountLegalEntityPublicHashedId) { _clientMock = new Mock(); _clientMock.Setup(c => c.GetEditVacancyInfoAsync(employerAccountId)).Returns(Task.FromResult( @@ -85,7 +85,8 @@ private LegalEntityAgreementService GetLegalEntityAgreementService(string employ { new LegalEntity { - AccountLegalEntityPublicHashedId = AccountLegalEntityPublicHashedId, + LegalEntityId = legalEntityId, + AccountLegalEntityPublicHashedId = accountLegalEntityPublicHashedId, HasLegalEntityAgreement = hasLegalEntityAgreement } } From 1dd5c4a0ec47ca4f3321e9b548375dec76e62901 Mon Sep 17 00:00:00 2001 From: Shoma Gujjar Date: Mon, 3 Aug 2020 15:27:46 +0100 Subject: [PATCH 09/12] CON-1186-fix failing build --- .../Shared.Web/Services/LegalEntityAgreementServiceTests.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Shared/UnitTests/Shared.Web/Services/LegalEntityAgreementServiceTests.cs b/src/Shared/UnitTests/Shared.Web/Services/LegalEntityAgreementServiceTests.cs index 4eea950f61..df5dade0f9 100644 --- a/src/Shared/UnitTests/Shared.Web/Services/LegalEntityAgreementServiceTests.cs +++ b/src/Shared/UnitTests/Shared.Web/Services/LegalEntityAgreementServiceTests.cs @@ -97,6 +97,7 @@ private LegalEntityAgreementService GetLegalEntityAgreementService(string employ { new LegalEntity { + LegalEntityId = employerServiceLegalEntityId, AccountLegalEntityPublicHashedId = accountLegalEntityPublicHashedId, HasLegalEntityAgreement = employerServiceHasLegalEntityAgreement } From 72377aab482ac686369f2c4df7387c2124910267 Mon Sep 17 00:00:00 2001 From: Shoma Gujjar Date: Tue, 4 Aug 2020 22:38:58 +0100 Subject: [PATCH 10/12] CON-1186-update employer profile --- .../Orchestrators/Part1/LocationOrchestrator.cs | 7 ++++++- .../Orchestrators/Part2/AboutEmployerOrchestrator.cs | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Employer/Employer.Web/Orchestrators/Part1/LocationOrchestrator.cs b/src/Employer/Employer.Web/Orchestrators/Part1/LocationOrchestrator.cs index edc35ea3c9..312511c11f 100644 --- a/src/Employer/Employer.Web/Orchestrators/Part1/LocationOrchestrator.cs +++ b/src/Employer/Employer.Web/Orchestrators/Part1/LocationOrchestrator.cs @@ -121,7 +121,7 @@ public async Task PostLocationEditModelAsync( var vacancy = vacancyTask.Result; var editVacancyInfo = employerVacancyInfoTask.Result; - var accountLegalEntityPublicHashedId = employerInfoModel?.AccountLegalEntityPublicHashedId != null + var accountLegalEntityPublicHashedId = !string.IsNullOrEmpty(employerInfoModel?.AccountLegalEntityPublicHashedId) ? employerInfoModel.AccountLegalEntityPublicHashedId : vacancy.AccountLegalEntityPublicHashedId; @@ -185,6 +185,11 @@ private async Task UpdateEmployerProfile(VacancyEmployerInfoModel employerInfoMo EmployerProfile employerProfile, Address address, VacancyUser user) { var updateProfile = false; + if (string.IsNullOrEmpty(employerProfile.AccountLegalEntityPublicHashedId) && !string.IsNullOrEmpty(employerInfoModel?.AccountLegalEntityPublicHashedId)) + { + updateProfile = true; + employerProfile.AccountLegalEntityPublicHashedId = employerInfoModel.AccountLegalEntityPublicHashedId; + } if (employerInfoModel != null && employerInfoModel.EmployerIdentityOption == EmployerIdentityOption.NewTradingName) { updateProfile = true; diff --git a/src/Employer/Employer.Web/Orchestrators/Part2/AboutEmployerOrchestrator.cs b/src/Employer/Employer.Web/Orchestrators/Part2/AboutEmployerOrchestrator.cs index 8583bf4a52..4ba371821c 100644 --- a/src/Employer/Employer.Web/Orchestrators/Part2/AboutEmployerOrchestrator.cs +++ b/src/Employer/Employer.Web/Orchestrators/Part2/AboutEmployerOrchestrator.cs @@ -5,6 +5,7 @@ using Esfa.Recruit.Employer.Web.RouteModel; using Esfa.Recruit.Employer.Web.ViewModels; using Esfa.Recruit.Employer.Web.ViewModels.AboutEmployer; +using Esfa.Recruit.Employer.Web.ViewModels.Part2.AboutEmployer; using Esfa.Recruit.Shared.Web.Orchestrators; using Esfa.Recruit.Shared.Web.Services; using Esfa.Recruit.Vacancies.Client.Application.Validation; @@ -86,7 +87,8 @@ private async Task UpdateEmployerProfileAsync(Vacancy vacancy, string employerDe if (employerProfile == null) { - throw new NullReferenceException($"No Employer Profile was found for employerAccount: {vacancy.EmployerAccountId}, legalEntity: {vacancy.LegalEntityId}"); + throw new NullReferenceException($"No Employer Profile was found for employerAccount: {vacancy.EmployerAccountId}, " + + $"accountLegalEntityPublicHashedId : {vacancy.AccountLegalEntityPublicHashedId}"); } if (employerProfile.AboutOrganisation != employerDescription) From fd2e7579ba1836623358f0d6c81cadee0fdcc1ee Mon Sep 17 00:00:00 2001 From: Shoma Gujjar Date: Wed, 5 Aug 2020 11:22:14 +0100 Subject: [PATCH 11/12] CON-1186-add PR comments --- .../Orchestrators/Part1/LocationOrchestrator.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Provider/Provider.Web/Orchestrators/Part1/LocationOrchestrator.cs b/src/Provider/Provider.Web/Orchestrators/Part1/LocationOrchestrator.cs index ab2c8ff504..f1b2e0e71c 100644 --- a/src/Provider/Provider.Web/Orchestrators/Part1/LocationOrchestrator.cs +++ b/src/Provider/Provider.Web/Orchestrators/Part1/LocationOrchestrator.cs @@ -62,8 +62,9 @@ public async Task GetLocationViewModelAsync( var vacancy = await Utility.GetAuthorisedVacancyForEditAsync( _providerVacancyClient, _recruitVacancyClient, vrm, RouteNames.Location_Get); - var accountLegalEntityPublicHashedId = employerInfoModel?.AccountLegalEntityPublicHashedId ?? vacancy.AccountLegalEntityPublicHashedId; - + var accountLegalEntityPublicHashedId = !string.IsNullOrEmpty(employerInfoModel?.AccountLegalEntityPublicHashedId) + ? employerInfoModel.AccountLegalEntityPublicHashedId : vacancy.AccountLegalEntityPublicHashedId; + var vm = new LocationViewModel(); vm.PageInfo = Utility.GetPartOnePageInfo(vacancy); @@ -111,7 +112,8 @@ public async Task PostLocationEditModelAsync( var vacancy = await Utility.GetAuthorisedVacancyForEditAsync(_providerVacancyClient, _recruitVacancyClient, locationEditModel, RouteNames.Location_Post); - var accountLegalEntityPublicHashedId = employerInfoModel?.AccountLegalEntityPublicHashedId ?? vacancy.AccountLegalEntityPublicHashedId; + var accountLegalEntityPublicHashedId = !string.IsNullOrEmpty(employerInfoModel?.AccountLegalEntityPublicHashedId) + ? employerInfoModel.AccountLegalEntityPublicHashedId : vacancy.AccountLegalEntityPublicHashedId; var employerVacancyInfoTask = _providerVacancyClient.GetProviderEmployerVacancyDataAsync(ukprn, vacancy.EmployerAccountId); var employerProfileTask = _recruitVacancyClient.GetEmployerProfileAsync(vacancy.EmployerAccountId, accountLegalEntityPublicHashedId); From 2f0ad264228dfbbc95ba04c9bd95831062bc43ac Mon Sep 17 00:00:00 2001 From: Shoma Gujjar Date: Wed, 5 Aug 2020 11:54:51 +0100 Subject: [PATCH 12/12] CON-1186-fix build --- .../Orchestrators/Part2/AboutEmployerOrchestrator.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Employer/Employer.Web/Orchestrators/Part2/AboutEmployerOrchestrator.cs b/src/Employer/Employer.Web/Orchestrators/Part2/AboutEmployerOrchestrator.cs index 4ba371821c..2d9aa7cdb3 100644 --- a/src/Employer/Employer.Web/Orchestrators/Part2/AboutEmployerOrchestrator.cs +++ b/src/Employer/Employer.Web/Orchestrators/Part2/AboutEmployerOrchestrator.cs @@ -5,7 +5,6 @@ using Esfa.Recruit.Employer.Web.RouteModel; using Esfa.Recruit.Employer.Web.ViewModels; using Esfa.Recruit.Employer.Web.ViewModels.AboutEmployer; -using Esfa.Recruit.Employer.Web.ViewModels.Part2.AboutEmployer; using Esfa.Recruit.Shared.Web.Orchestrators; using Esfa.Recruit.Shared.Web.Services; using Esfa.Recruit.Vacancies.Client.Application.Validation;