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..2e4f5f5be7 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.SelectedOrganisationId = info.AccountLegalEntityPublicHashedId; } if (vm.HasOnlyOneOrganisation) @@ -60,16 +60,16 @@ public async Task Employer(EmployerEditModel m, [FromQuery] bool 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.SelectedOrganisationId) { - info.LegalEntityId = m.SelectedOrganisationId; + info.AccountLegalEntityPublicHashedId = m.SelectedOrganisationId; 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..59fdbeafef 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..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, long? selectedLegalEntityId = 0) + public async Task GetEmployerViewModelAsync(VacancyRouteModel vrm, string searchTerm, int? requestedPageNo, string selectedAccountLegalEntityPublicHashedId) { 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, + SelectedOrganisationId = vacancy.AccountLegalEntityPublicHashedId }; - 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)) @@ -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(selectedAccountLegalEntityPublicHashedId) + ? filteredLegalEntities.FindIndex(le => le.Id == selectedAccountLegalEntityPublicHashedId) + 1 : NotFoundIndex; setPage = GetPageNo(requestedPageNo, setPage, totalNumberOfPages, indexOfSelectedLegalEntity); @@ -82,12 +82,12 @@ 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) + if (vm.VacancyEmployerInfoModel.AccountLegalEntityPublicHashedId == null && vm.HasOnlyOneOrganisation) { - vm.VacancyEmployerInfoModel.LegalEntityId = vm.Organisations.First().Id; + 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 daf150a155..312511c11f 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 = !string.IsNullOrEmpty(employerInfoModel?.AccountLegalEntityPublicHashedId) + ? 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; @@ -181,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; @@ -202,7 +211,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/Employer/Employer.Web/Orchestrators/Part2/AboutEmployerOrchestrator.cs b/src/Employer/Employer.Web/Orchestrators/Part2/AboutEmployerOrchestrator.cs index 28c5cbbf1f..2d9aa7cdb3 100644 --- a/src/Employer/Employer.Web/Orchestrators/Part2/AboutEmployerOrchestrator.cs +++ b/src/Employer/Employer.Web/Orchestrators/Part2/AboutEmployerOrchestrator.cs @@ -82,11 +82,12 @@ 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) { - 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) 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..568ed94dc2 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 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 4c2d489800..c2e05f9037 100644 --- a/src/Employer/Employer.Web/ViewModels/Part1/Employer/EmployerViewModel.cs +++ b/src/Employer/Employer.Web/ViewModels/Part1/Employer/EmployerViewModel.cs @@ -17,13 +17,12 @@ public class EmployerViewModel : VacancyRouteModel public PartOnePageInfoViewModel PageInfo { get; internal set; } public PagerViewModel Pager { get; internal set; } - public IList OrderedFieldNames => new List { - nameof(SelectedOrganisationId) + nameof(SelectedOrganisationId ) }; - public long? SelectedOrganisationId { get; internal set; } + public string SelectedOrganisationId { get; internal set; } public VacancyEmployerInfoModel VacancyEmployerInfoModel { get; internal set; } @@ -38,18 +37,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(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; } } } diff --git a/src/Employer/Employer.Web/Views/DeleteVacancy/Delete.cshtml b/src/Employer/Employer.Web/Views/DeleteVacancy/Delete.cshtml index 48bc5cc44c..d47da801cb 100644 --- a/src/Employer/Employer.Web/Views/DeleteVacancy/Delete.cshtml +++ b/src/Employer/Employer.Web/Views/DeleteVacancy/Delete.cshtml @@ -1,6 +1,7 @@ @model Esfa.Recruit.Employer.Web.ViewModels.DeleteVacancy.DeleteViewModel @{ ViewBag.Vpv = "/recruitment/employer/page-delete-vacancy"; + ViewBag.Title = "Are you sure you want to delete this advert?"; }
@@ -8,7 +9,7 @@

@Model.Title

-

Are you sure you want to delete the vacancy?

+

Are you sure you want to delete this advert?

@@ -16,11 +17,11 @@
- +
- +
diff --git a/src/Employer/UnitTests/Employer.Web/Orchestrators/CloneVacancyOrchestratorTest/CloneVacancyOrchestratorTestBase.cs b/src/Employer/UnitTests/Employer.Web/Orchestrators/CloneVacancyOrchestratorTest/CloneVacancyOrchestratorTestBase.cs index ddad3964d7..421c80bc23 100644 --- a/src/Employer/UnitTests/Employer.Web/Orchestrators/CloneVacancyOrchestratorTest/CloneVacancyOrchestratorTestBase.cs +++ b/src/Employer/UnitTests/Employer.Web/Orchestrators/CloneVacancyOrchestratorTest/CloneVacancyOrchestratorTestBase.cs @@ -19,7 +19,7 @@ public abstract class CloneVacancyOrchestratorTestBase internal Vacancy SourceVacancy => new Vacancy { Id = SourceVacancyId, - LegalEntityId = 1, + AccountLegalEntityPublicHashedId = "1", EmployerAccountId = EmployerAccountId, Status = VacancyStatus.Live, StartDate = SourceStartDate, diff --git a/src/Employer/UnitTests/Employer.Web/Services/LegalEntityAgreementServiceTests.cs b/src/Employer/UnitTests/Employer.Web/Services/LegalEntityAgreementServiceTests.cs index d6a163a523..2a0b572099 100644 --- a/src/Employer/UnitTests/Employer.Web/Services/LegalEntityAgreementServiceTests.cs +++ b/src/Employer/UnitTests/Employer.Web/Services/LegalEntityAgreementServiceTests.cs @@ -13,16 +13,16 @@ namespace Esfa.Recruit.Employer.UnitTests.Employer.Web.Services public class LegalEntityAgreementServiceTests { const string EmployerAccountId = "ABCDEF"; - const long LegalEntityId = 1234; + const string AccountLegalEntityPublicHashedId = "ABCDEF"; private Mock _clientMock; [Fact] public void HasLegalEntityAgreementAsync_ShouldReturnFalseIfNoMatchingLegalEntity() { - var sut = GetLegalEntityAgreementService(EmployerAccountId, 5678, true, 5678, true); + var sut = GetLegalEntityAgreementService(EmployerAccountId, true, "5678",true, "5678"); - 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); @@ -31,30 +31,32 @@ public void HasLegalEntityAgreementAsync_ShouldReturnFalseIfNoMatchingLegalEntit [Fact] public void HasLegalEntityAgreementAsync_ShouldNotCheckEmployerServiceWhenHasAgreement() { - var sut = GetLegalEntityAgreementService(EmployerAccountId, LegalEntityId, true, LegalEntityId, true); + var sut = GetLegalEntityAgreementService(EmployerAccountId, true, AccountLegalEntityPublicHashedId,true, AccountLegalEntityPublicHashedId); - 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); } - [Fact] public void HasLegalEntityAgreementAsync_ShouldCheckEmployerServiceWhenHasNoAgreement() + [Fact] + public void HasLegalEntityAgreementAsync_ShouldCheckEmployerServiceWhenHasNoAgreement() { - var sut = GetLegalEntityAgreementService(EmployerAccountId, LegalEntityId, false, LegalEntityId, true); + var sut = GetLegalEntityAgreementService(EmployerAccountId, false, AccountLegalEntityPublicHashedId,true, AccountLegalEntityPublicHashedId); - 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); _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); + var sut = GetLegalEntityAgreementService(EmployerAccountId, false, AccountLegalEntityPublicHashedId,false, AccountLegalEntityPublicHashedId); - 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); @@ -64,16 +66,18 @@ [Fact] public void HasLegalEntityAgreementAsync_ShouldReturnFalseWhenEmployerSer [Fact] public void HasLegalEntityAgreementAsync_ShouldReturnFalseWhenEmployerServiceCantLocateLegalEntity() { - var sut = GetLegalEntityAgreementService(EmployerAccountId, LegalEntityId, false, 5678, true); + var sut = GetLegalEntityAgreementService(EmployerAccountId, false, "5678", true, AccountLegalEntityPublicHashedId); - 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); _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, + bool hasLegalEntityAgreement, string employerServiceAccountLegalEntityPublicHashedId, + bool employerServiceHasLegalEntityAgreement, string accountLegalEntityPublicHashedId) { _clientMock = new Mock(); _clientMock.Setup(c => c.GetEditVacancyInfoAsync(employerAccountId)).Returns(Task.FromResult( @@ -81,7 +85,10 @@ private LegalEntityAgreementService GetLegalEntityAgreementService(string employ { LegalEntities = new List { - new LegalEntity{LegalEntityId = legalEntityId, HasLegalEntityAgreement = hasLegalEntityAgreement} + new LegalEntity{ + HasLegalEntityAgreement = hasLegalEntityAgreement, + AccountLegalEntityPublicHashedId = accountLegalEntityPublicHashedId + } } })); @@ -90,8 +97,8 @@ private LegalEntityAgreementService GetLegalEntityAgreementService(string employ { new LegalEntity { - LegalEntityId = employerServiceLegalEntityId, - HasLegalEntityAgreement = employerServiceHasLegalEntityAgreement + HasLegalEntityAgreement = employerServiceHasLegalEntityAgreement, + AccountLegalEntityPublicHashedId = employerServiceAccountLegalEntityPublicHashedId } } .AsEnumerable())); diff --git a/src/Employer/UnitTests/Recruit.Vacancies.Client/Infrastructure/Mappings/LegalEntityMapperTests/WhenMappingLegalEntity.cs b/src/Employer/UnitTests/Recruit.Vacancies.Client/Infrastructure/Mappings/LegalEntityMapperTests/WhenMappingLegalEntity.cs index 8c0de5b511..965fa048f3 100644 --- a/src/Employer/UnitTests/Recruit.Vacancies.Client/Infrastructure/Mappings/LegalEntityMapperTests/WhenMappingLegalEntity.cs +++ b/src/Employer/UnitTests/Recruit.Vacancies.Client/Infrastructure/Mappings/LegalEntityMapperTests/WhenMappingLegalEntity.cs @@ -25,7 +25,6 @@ public void ThenReturnsCorrectlyPolulatedLegalEntity() var actual = LegalEntityMapper.MapFromAccountApiLegalEntity(expected); // Assert - actual.LegalEntityId.Should().Be(expected.LegalEntityId); actual.AccountLegalEntityPublicHashedId.Should().Be(expected.AccountLegalEntityPublicHashedId); actual.Name.Should().Be(expected.Name); actual.HasLegalEntityAgreement.Should().BeFalse(); diff --git a/src/Jobs/Recruit.Vacancies.Jobs.UnitTests/DomainEvents/Handlers/Provider/ProviderBlockedDomainEventHandlerTests/HandleAsyncTests.cs b/src/Jobs/Recruit.Vacancies.Jobs.UnitTests/DomainEvents/Handlers/Provider/ProviderBlockedDomainEventHandlerTests/HandleAsyncTests.cs index bafd4309ce..7d578147d9 100644 --- a/src/Jobs/Recruit.Vacancies.Jobs.UnitTests/DomainEvents/Handlers/Provider/ProviderBlockedDomainEventHandlerTests/HandleAsyncTests.cs +++ b/src/Jobs/Recruit.Vacancies.Jobs.UnitTests/DomainEvents/Handlers/Provider/ProviderBlockedDomainEventHandlerTests/HandleAsyncTests.cs @@ -7,11 +7,12 @@ using Esfa.Recruit.Vacancies.Client.Domain.Events; using Esfa.Recruit.Vacancies.Client.Domain.Models; using Esfa.Recruit.Vacancies.Client.Infrastructure.QueryStore.Projections.EditVacancyInfo; +using Esfa.Recruit.Vacancies.Jobs.UnitTests.DomainEvents.Handlers.Provider.ProviderBlockedDomainEventHandlerTests; using Moq; using Newtonsoft.Json; using Xunit; -namespace Esfa.Recruit.Vacancies.Jobs.UnitTests.DomainEvents.Handlers.Provider.ProviderBlockedDomainEventHandlerTests +namespace Recruit.Vacancies.Jobs.UnitTests.DomainEvents.Handlers.Provider.ProviderBlockedDomainEventHandlerTests { public class HandleAsyncTests : ProviderBlockedDomainEventHandlerTestBase { @@ -157,8 +158,8 @@ protected ProviderEditVacancyInfo GetProviderProfile() EmployerAccountId = _employerAccount1, LegalEntities = new List() { - new LegalEntity() { LegalEntityId = 1, AccountLegalEntityPublicHashedId = _legalEntity1 }, - new LegalEntity() { LegalEntityId = 2, AccountLegalEntityPublicHashedId = _legalEntity2 } + new LegalEntity() { AccountLegalEntityPublicHashedId = _legalEntity1 }, + new LegalEntity() { AccountLegalEntityPublicHashedId = _legalEntity2 } } }, new EmployerInfo { EmployerAccountId = _employerAccount3 } diff --git a/src/Jobs/Recruit.Vacancies.Jobs.UnitTests/ExternalSystemEventHandlers/UpdatedPermissionsExternalSystemEventHandlerTests.cs b/src/Jobs/Recruit.Vacancies.Jobs.UnitTests/ExternalSystemEventHandlers/UpdatedPermissionsExternalSystemEventHandlerTests.cs index 8744a0ff6c..90938d9b20 100644 --- a/src/Jobs/Recruit.Vacancies.Jobs.UnitTests/ExternalSystemEventHandlers/UpdatedPermissionsExternalSystemEventHandlerTests.cs +++ b/src/Jobs/Recruit.Vacancies.Jobs.UnitTests/ExternalSystemEventHandlers/UpdatedPermissionsExternalSystemEventHandlerTests.cs @@ -7,8 +7,6 @@ using Esfa.Recruit.Vacancies.Client.Application.Queues; using Esfa.Recruit.Vacancies.Client.Application.Queues.Messages; using Esfa.Recruit.Vacancies.Client.Domain.Messaging; -using Esfa.Recruit.Vacancies.Client.Domain.Repositories; -using Esfa.Recruit.Vacancies.Client.Infrastructure.QueryStore; using Esfa.Recruit.Vacancies.Client.Infrastructure.Services.EmployerAccount; using Esfa.Recruit.Vacancies.Jobs.Configuration; using Esfa.Recruit.Vacancies.Jobs.ExternalSystemEventHandlers; @@ -21,7 +19,7 @@ using SFA.DAS.ProviderRelationships.Types.Models; using Xunit; -namespace Esfa.Recruit.Vacancies.Jobs.UnitTests.ExternalSystemEventHandlers +namespace Recruit.Vacancies.Jobs.UnitTests.ExternalSystemEventHandlers { public class UpdatedPermissionsExternalSystemEventHandlerTests { diff --git a/src/Jobs/Recruit.Vacancies.Jobs.UnitTests/Jobs/TransferVacanciesFromProviderJobTests.cs b/src/Jobs/Recruit.Vacancies.Jobs.UnitTests/Jobs/TransferVacanciesFromProviderJobTests.cs index 2f6304d2ec..f967d9c4b0 100644 --- a/src/Jobs/Recruit.Vacancies.Jobs.UnitTests/Jobs/TransferVacanciesFromProviderJobTests.cs +++ b/src/Jobs/Recruit.Vacancies.Jobs.UnitTests/Jobs/TransferVacanciesFromProviderJobTests.cs @@ -13,7 +13,7 @@ using Moq; using Xunit; -namespace Esfa.Recruit.Vacancies.Jobs.UnitTests.Jobs +namespace Recruit.Vacancies.Jobs.UnitTests.Jobs { public class TransferVacanciesFromProviderJobTests { @@ -35,28 +35,34 @@ public TransferVacanciesFromProviderJobTests() public async Task GivenRequest_WhenNoMatchingVacanciesToTransfer_AndProviderHasManyLegalEntityPermissions_ThenShouldNotQueueAnyTransfers() { const long Ukprn = 1; - const long LegalEntityId = 2; + const string AccountLegalEntityPublicHashedId = "2"; const string EmployerAccountId = "employer-account-id"; - _mockVacancyQuery.Setup(x => x.GetProviderOwnedVacanciesForLegalEntityAsync(Ukprn, LegalEntityId)) + _mockVacancyQuery.Setup(x => x.GetProviderOwnedVacanciesForLegalEntityAsync(Ukprn, AccountLegalEntityPublicHashedId)) .ReturnsAsync(Enumerable.Empty()); var employerInfo = new EmployerInfo { LegalEntities = new List { - new LegalEntity{LegalEntityId = LegalEntityId}, - new LegalEntity{LegalEntityId = 12345} + new LegalEntity + { + AccountLegalEntityPublicHashedId = "2" + }, + new LegalEntity + { + AccountLegalEntityPublicHashedId = "12345" + } } }; _mockQueryStoreReader.Setup(q => q.GetProviderEmployerVacancyDataAsync(Ukprn, EmployerAccountId)) .ReturnsAsync(employerInfo); - await _sut.Run(Ukprn, EmployerAccountId, LegalEntityId, Guid.NewGuid(), string.Empty, string.Empty, TransferReason.EmployerRevokedPermission); + await _sut.Run(Ukprn, EmployerAccountId, AccountLegalEntityPublicHashedId, Guid.NewGuid(), string.Empty, string.Empty, TransferReason.EmployerRevokedPermission); _mockRecruitQueueService.Verify(x => x.AddMessageAsync(It.IsAny()), Times.Never); - _mockVacancyQuery.Verify(x => x.GetProviderOwnedVacanciesForEmployerWithoutLegalEntityAsync(It.IsAny(), It.IsAny()), Times.Never); + _mockVacancyQuery.Verify(x => x.GetProviderOwnedVacanciesForEmployerWithoutAccountLegalEntityPublicHashedIdAsync(It.IsAny(), It.IsAny()), Times.Never); } [Fact] @@ -68,27 +74,30 @@ public async Task GivenRequest_WhenMatchingVacanciesToTransfer_AndProviderHasSin const string UserEmail = "test@test.com"; const string UserName = "John Smith"; const long Ukprn = 1; - const long LegalEntityId = 2; + const string AccountLegalEntityPublicHashedId = "2"; const string EmployerAccountId = "employer-account-id"; - _mockVacancyQuery.Setup(x => x.GetProviderOwnedVacanciesForLegalEntityAsync(Ukprn, LegalEntityId)) + _mockVacancyQuery.Setup(x => x.GetProviderOwnedVacanciesForLegalEntityAsync(Ukprn, AccountLegalEntityPublicHashedId)) .ReturnsAsync(new Fixture().CreateMany(NoOfMatchingVacancies)); var employerInfo = new EmployerInfo { LegalEntities = new List { - new LegalEntity{LegalEntityId = LegalEntityId} + new LegalEntity + { + AccountLegalEntityPublicHashedId = AccountLegalEntityPublicHashedId + } } }; _mockQueryStoreReader.Setup(q => q.GetProviderEmployerVacancyDataAsync(Ukprn, EmployerAccountId)) .ReturnsAsync(employerInfo); - _mockVacancyQuery.Setup(x => x.GetProviderOwnedVacanciesForEmployerWithoutLegalEntityAsync(Ukprn, EmployerAccountId)) + _mockVacancyQuery.Setup(x => x.GetProviderOwnedVacanciesForEmployerWithoutAccountLegalEntityPublicHashedIdAsync(Ukprn, EmployerAccountId)) .ReturnsAsync(new Fixture().CreateMany(NoOfVacanciesWithoutLegalEntity)); - await _sut.Run(Ukprn, EmployerAccountId, LegalEntityId, userRef, UserEmail, UserName, TransferReason.EmployerRevokedPermission); + await _sut.Run(Ukprn, EmployerAccountId, AccountLegalEntityPublicHashedId, userRef, UserEmail, UserName, TransferReason.EmployerRevokedPermission); var expectedCallCount = NoOfMatchingVacancies + NoOfVacanciesWithoutLegalEntity; _mockRecruitQueueService.Verify(x => x.AddMessageAsync(It.IsAny()), Times.Exactly(expectedCallCount)); @@ -102,27 +111,33 @@ public async Task GivenRequest_WhenMatchingVacanciesToTransfer_AndProviderHasMan const string UserEmail = "test@test.com"; const string UserName = "John Smith"; const long Ukprn = 1; - const long LegalEntityId = 2; + const string AccountLegalEntityPublicHashedId = "2"; const string EmployerAccountId = "employer-account-id"; - _mockVacancyQuery.Setup(x => x.GetProviderOwnedVacanciesForLegalEntityAsync(Ukprn, LegalEntityId)) + _mockVacancyQuery.Setup(x => x.GetProviderOwnedVacanciesForLegalEntityAsync(Ukprn, AccountLegalEntityPublicHashedId)) .ReturnsAsync(new Fixture().CreateMany(NoOfMatchingVacancies)); var employerInfo = new EmployerInfo { LegalEntities = new List { - new LegalEntity{LegalEntityId = LegalEntityId}, - new LegalEntity{LegalEntityId = 1234} + new LegalEntity + { + AccountLegalEntityPublicHashedId = AccountLegalEntityPublicHashedId + }, + new LegalEntity + { + AccountLegalEntityPublicHashedId = "1234" + } } }; _mockQueryStoreReader.Setup(q => q.GetProviderEmployerVacancyDataAsync(Ukprn, EmployerAccountId)) .ReturnsAsync(employerInfo); - await _sut.Run(Ukprn, EmployerAccountId, LegalEntityId, userRef, UserEmail, UserName, TransferReason.EmployerRevokedPermission); + await _sut.Run(Ukprn, EmployerAccountId, AccountLegalEntityPublicHashedId, userRef, UserEmail, UserName, TransferReason.EmployerRevokedPermission); - _mockVacancyQuery.Verify(x => x.GetProviderOwnedVacanciesForEmployerWithoutLegalEntityAsync(It.IsAny(), It.IsAny()), Times.Never); + _mockVacancyQuery.Verify(x => x.GetProviderOwnedVacanciesForEmployerWithoutAccountLegalEntityPublicHashedIdAsync(It.IsAny(), It.IsAny()), Times.Never); _mockRecruitQueueService.Verify(x => x.AddMessageAsync(It.IsAny()), Times.Exactly(NoOfMatchingVacancies)); } } 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/Jobs/Recruit.Vacancies.Jobs/DomainEvents/Handlers/Provider/ProviderBlockedDomainEventHandler.cs b/src/Jobs/Recruit.Vacancies.Jobs/DomainEvents/Handlers/Provider/ProviderBlockedDomainEventHandler.cs index e99dd1b6da..8bea65d1d3 100644 --- a/src/Jobs/Recruit.Vacancies.Jobs/DomainEvents/Handlers/Provider/ProviderBlockedDomainEventHandler.cs +++ b/src/Jobs/Recruit.Vacancies.Jobs/DomainEvents/Handlers/Provider/ProviderBlockedDomainEventHandler.cs @@ -78,12 +78,12 @@ private List RaiseEventsToRevokePermission(IEnumerable emplo foreach (var legalEntity in employer.LegalEntities) { - _logger.LogInformation($"Queuing to revoke provider {ukprn} permission on account {employer.EmployerAccountId} for legal entity {legalEntity.LegalEntityId}."); + _logger.LogInformation($"Queuing to revoke provider {ukprn} permission on account {employer.EmployerAccountId} " + + $"for AccountLegalEntityPublicHashedId {legalEntity.AccountLegalEntityPublicHashedId}."); var providerBlockedOnLegalEntityEvent = new ProviderBlockedOnLegalEntityEvent() { Ukprn = ukprn, EmployerAccountId = employer.EmployerAccountId, - LegalEntityId = legalEntity.LegalEntityId, AccountLegalEntityPublicHashedId = legalEntity.AccountLegalEntityPublicHashedId }; diff --git a/src/Jobs/Recruit.Vacancies.Jobs/DomainEvents/Handlers/Provider/ProviderBlockedOnLegalEntityDomainEventHandler.cs b/src/Jobs/Recruit.Vacancies.Jobs/DomainEvents/Handlers/Provider/ProviderBlockedOnLegalEntityDomainEventHandler.cs index 9f30a3c5c8..619e010e48 100644 --- a/src/Jobs/Recruit.Vacancies.Jobs/DomainEvents/Handlers/Provider/ProviderBlockedOnLegalEntityDomainEventHandler.cs +++ b/src/Jobs/Recruit.Vacancies.Jobs/DomainEvents/Handlers/Provider/ProviderBlockedOnLegalEntityDomainEventHandler.cs @@ -1,7 +1,5 @@ -using System.Linq; using System.Threading.Tasks; using Esfa.Recruit.Vacancies.Client.Domain.Events; -using Esfa.Recruit.Vacancies.Client.Infrastructure.Services.EmployerAccount; using Esfa.Recruit.Vacancies.Client.Infrastructure.Services.ProviderRelationship; using Microsoft.Extensions.Logging; @@ -9,16 +7,12 @@ namespace Esfa.Recruit.Vacancies.Jobs.DomainEvents.Handlers.Provider { public class ProviderBlockedOnLegalEntityDomainEventHandler : DomainEventHandler, IDomainEventHandler { - private readonly IEmployerAccountProvider _employerAccountProvider; private readonly IProviderRelationshipsService _providerRelationshipsService; private readonly ILogger _logger; - public ProviderBlockedOnLegalEntityDomainEventHandler( - IEmployerAccountProvider employerAccountProvider, - IProviderRelationshipsService providerRelationshipsService, + public ProviderBlockedOnLegalEntityDomainEventHandler(IProviderRelationshipsService providerRelationshipsService, ILogger logger) : base(logger) { _logger = logger; - _employerAccountProvider = employerAccountProvider; _providerRelationshipsService = providerRelationshipsService; } @@ -26,11 +20,11 @@ public async Task HandleAsync(string eventPayload) { var eventData = DeserializeEvent(eventPayload); - _logger.LogInformation($"Attempting to revoke provider {eventData.Ukprn} permission on account {eventData.EmployerAccountId} with public hash {eventData.AccountLegalEntityPublicHashedId} for legal entity {eventData.LegalEntityId}."); + _logger.LogInformation($"Attempting to revoke provider {eventData.Ukprn} permission on account {eventData.EmployerAccountId} with public hash {eventData.AccountLegalEntityPublicHashedId} for legal entity {eventData.AccountLegalEntityPublicHashedId}."); await _providerRelationshipsService.RevokeProviderPermissionToRecruitAsync(eventData.Ukprn, eventData.AccountLegalEntityPublicHashedId); - _logger.LogInformation($"Successfully revoked provider {eventData.Ukprn} permission on account {eventData.EmployerAccountId} for legal entity {eventData.LegalEntityId}."); + _logger.LogInformation($"Successfully revoked provider {eventData.Ukprn} permission on account {eventData.EmployerAccountId} for legal entity {eventData.AccountLegalEntityPublicHashedId}."); } } } \ No newline at end of file diff --git a/src/Jobs/Recruit.Vacancies.Jobs/ExternalSystemEventHandlers/UpdatedPermissionsExternalSystemEventsHandler.cs b/src/Jobs/Recruit.Vacancies.Jobs/ExternalSystemEventHandlers/UpdatedPermissionsExternalSystemEventsHandler.cs index f0cdbcc6e5..f9541045f3 100644 --- a/src/Jobs/Recruit.Vacancies.Jobs/ExternalSystemEventHandlers/UpdatedPermissionsExternalSystemEventsHandler.cs +++ b/src/Jobs/Recruit.Vacancies.Jobs/ExternalSystemEventHandlers/UpdatedPermissionsExternalSystemEventsHandler.cs @@ -74,7 +74,6 @@ await _recruitQueueService.AddMessageAsync(new TransferVacanciesFromProviderQueu { Ukprn = message.Ukprn, EmployerAccountId = employerAccountId, - LegalEntityId = legalEntity.LegalEntityId, UserRef = message.UserRef.Value, UserEmailAddress = message.UserEmailAddress, UserName = $"{message.UserFirstName} {message.UserLastName}", diff --git a/src/Jobs/Recruit.Vacancies.Jobs/Jobs/TransferVacanciesFromProviderJob.cs b/src/Jobs/Recruit.Vacancies.Jobs/Jobs/TransferVacanciesFromProviderJob.cs index e54b3c2570..ec86d48dc2 100644 --- a/src/Jobs/Recruit.Vacancies.Jobs/Jobs/TransferVacanciesFromProviderJob.cs +++ b/src/Jobs/Recruit.Vacancies.Jobs/Jobs/TransferVacanciesFromProviderJob.cs @@ -23,10 +23,10 @@ public TransferVacanciesFromProviderJob(IVacancyQuery vacanciesQuery, IRecruitQu _queryStoreReader = queryStoreReader; } - public async Task Run(long ukprn, string employerAccountId, long legalEntityId, Guid userRef, string userEmail, string userName, TransferReason transferReason) + public async Task Run(long ukprn, string employerAccountId, string accountLegalEntityPublicHashedId, Guid userRef, string userEmail, string userName, TransferReason transferReason) { - var vacanciesTask = _vacanciesQuery.GetProviderOwnedVacanciesForLegalEntityAsync(ukprn, legalEntityId); - var vacanciesWithoutLegalEntityIdTask = GetProviderOwnerVacanciesWithoutLegalEntityThatMustBeTransferred(ukprn, employerAccountId, legalEntityId); + var vacanciesTask = _vacanciesQuery.GetProviderOwnedVacanciesForLegalEntityAsync(ukprn, accountLegalEntityPublicHashedId); + var vacanciesWithoutLegalEntityIdTask = GetProviderOwnerVacanciesWithoutLegalEntityThatMustBeTransferred(ukprn, employerAccountId, accountLegalEntityPublicHashedId); await Task.WhenAll(vacanciesTask, vacanciesWithoutLegalEntityIdTask); @@ -44,14 +44,15 @@ public async Task Run(long ukprn, string employerAccountId, long legalEntityId, await Task.WhenAll(tasks); } - private async Task> GetProviderOwnerVacanciesWithoutLegalEntityThatMustBeTransferred(long ukprn, string employerAccountId, long legalEntityId) + private async Task> GetProviderOwnerVacanciesWithoutLegalEntityThatMustBeTransferred(long ukprn, string employerAccountId, string accountLegalEntityPublicHashedId) { var employer = await _queryStoreReader.GetProviderEmployerVacancyDataAsync(ukprn, employerAccountId); - var remainingLegalEntitiesCount = employer?.LegalEntities.Count(l => l.LegalEntityId != legalEntityId) ?? 0; + var remainingLegalEntitiesCount = employer?.LegalEntities.Count( + l => l.AccountLegalEntityPublicHashedId != accountLegalEntityPublicHashedId) ?? 0; - //We should only transfer vacancies without a legalEntityId when the provider cannot choose another legal entity + //We should only transfer vacancies without a accountLegalEntityPublicHashedId when the provider cannot choose another legal entity if (remainingLegalEntitiesCount == 0) - return await _vacanciesQuery.GetProviderOwnedVacanciesForEmployerWithoutLegalEntityAsync(ukprn, employerAccountId); + return await _vacanciesQuery.GetProviderOwnedVacanciesForEmployerWithoutAccountLegalEntityPublicHashedIdAsync(ukprn, employerAccountId); return Enumerable.Empty(); } diff --git a/src/Jobs/Recruit.Vacancies.Jobs/Triggers/QueueTriggers/PerformDataMigrationQueueTrigger.cs b/src/Jobs/Recruit.Vacancies.Jobs/Triggers/QueueTriggers/PerformDataMigrationQueueTrigger.cs index 82a4410b70..4ab0d7cf5d 100644 --- a/src/Jobs/Recruit.Vacancies.Jobs/Triggers/QueueTriggers/PerformDataMigrationQueueTrigger.cs +++ b/src/Jobs/Recruit.Vacancies.Jobs/Triggers/QueueTriggers/PerformDataMigrationQueueTrigger.cs @@ -59,9 +59,9 @@ private async Task PerformVacancyALEIdMigration(DataMigrationQueueMessage messag return; } - if (vacancy.LegalEntityId == 0) + if (vacancy.AccountLegalEntityPublicHashedId == "0") { - _logger.LogWarning($"{message.SerialNumber}: Missing legalEntity - Bypassing vacancy {vacancyId}"); + _logger.LogWarning($"{message.SerialNumber}: Missing AccountLegalEntityPublicHashedId - Bypassing vacancy {vacancyId}"); return; } @@ -78,7 +78,7 @@ private async Task PerformVacancyALEIdMigration(DataMigrationQueueMessage messag var legalEntities = await retryPolicy.ExecuteAsync(context => _employerAccountProvider.GetLegalEntitiesConnectedToAccountAsync(vacancy.EmployerAccountId), new Dictionary() {{ "apiCall", "employer details" }}); - selectedLegalEntity = legalEntities.FirstOrDefault(l => l.LegalEntityId == vacancy.LegalEntityId); + selectedLegalEntity = legalEntities.FirstOrDefault(l => l.AccountLegalEntityPublicHashedId == vacancy.AccountLegalEntityPublicHashedId); } catch (Exception ex) { diff --git a/src/Jobs/Recruit.Vacancies.Jobs/Triggers/QueueTriggers/TransferVacanciesFromProviderQueueTrigger.cs b/src/Jobs/Recruit.Vacancies.Jobs/Triggers/QueueTriggers/TransferVacanciesFromProviderQueueTrigger.cs index 427858dc0d..cb5b52dd48 100644 --- a/src/Jobs/Recruit.Vacancies.Jobs/Triggers/QueueTriggers/TransferVacanciesFromProviderQueueTrigger.cs +++ b/src/Jobs/Recruit.Vacancies.Jobs/Triggers/QueueTriggers/TransferVacanciesFromProviderQueueTrigger.cs @@ -47,7 +47,7 @@ public async Task TransferVacanciesFromProvider([QueueTrigger(QueueNames.Transfe { var queueMessage = JsonConvert.DeserializeObject(message); - await _runner.Run(queueMessage.Ukprn, queueMessage.EmployerAccountId, queueMessage.LegalEntityId, queueMessage.UserRef, queueMessage.UserEmailAddress, queueMessage.UserName, queueMessage.TransferReason); + await _runner.Run(queueMessage.Ukprn, queueMessage.EmployerAccountId, queueMessage.AccountLegalEntityPublicHashedId, queueMessage.UserRef, queueMessage.UserEmailAddress, queueMessage.UserName, queueMessage.TransferReason); _logger.LogInformation("Finished queueing vacancies to transfer from provider."); } 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 59e2ea79b1..f1b2e0e71c 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,8 +62,9 @@ public async Task GetLocationViewModelAsync( var vacancy = await Utility.GetAuthorisedVacancyForEditAsync( _providerVacancyClient, _recruitVacancyClient, vrm, RouteNames.Location_Get); - var legalEntityId = employerInfoModel?.LegalEntityId ?? vacancy.LegalEntityId; - + var accountLegalEntityPublicHashedId = !string.IsNullOrEmpty(employerInfoModel?.AccountLegalEntityPublicHashedId) + ? employerInfoModel.AccountLegalEntityPublicHashedId : vacancy.AccountLegalEntityPublicHashedId; + var vm = new LocationViewModel(); vm.PageInfo = Utility.GetPartOnePageInfo(vacancy); @@ -71,7 +73,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 +112,16 @@ public async Task PostLocationEditModelAsync( var vacancy = await Utility.GetAuthorisedVacancyForEditAsync(_providerVacancyClient, _recruitVacancyClient, locationEditModel, RouteNames.Location_Post); - var legalEntityId = employerInfoModel?.LegalEntityId ?? vacancy.LegalEntityId; + var accountLegalEntityPublicHashedId = !string.IsNullOrEmpty(employerInfoModel?.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 +137,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 +149,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 +162,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, @@ -193,7 +196,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/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/CloneVacancyOrchestratorTest/CloneVacancyOrchestratorTestBase.cs b/src/Provider/UnitTests/Provider.Web/Orchestrators/CloneVacancyOrchestratorTest/CloneVacancyOrchestratorTestBase.cs index 5b6d94a666..114dadf5f2 100644 --- a/src/Provider/UnitTests/Provider.Web/Orchestrators/CloneVacancyOrchestratorTest/CloneVacancyOrchestratorTestBase.cs +++ b/src/Provider/UnitTests/Provider.Web/Orchestrators/CloneVacancyOrchestratorTest/CloneVacancyOrchestratorTestBase.cs @@ -22,7 +22,7 @@ public abstract class CloneVacancyOrchestratorTestBase internal Vacancy SourceVacancy => new Vacancy { Id = SourceVacancyId, - LegalEntityId = 1, + AccountLegalEntityPublicHashedId = "1", TrainingProvider = TrainingProvider, Status = VacancyStatus.Live, StartDate = SourceStartDate, 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..8e2073fdfc 100644 --- a/src/Provider/UnitTests/Provider.Web/Orchestrators/VacancyPreviewOrchestratorTests.cs +++ b/src/Provider/UnitTests/Provider.Web/Orchestrators/VacancyPreviewOrchestratorTests.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; using System.Threading.Tasks; using AutoFixture; using Esfa.Recruit.Provider.Web.Configuration; @@ -8,13 +6,10 @@ using Esfa.Recruit.Provider.Web.Orchestrators; using Esfa.Recruit.Provider.Web.ViewModels.VacancyPreview; using Esfa.Recruit.Shared.Web.Services; -using Esfa.Recruit.Vacancies.Client.Application.Providers; -using Esfa.Recruit.Vacancies.Client.Application.Rules.VacancyRules; using Esfa.Recruit.Vacancies.Client.Application.Validation; using Esfa.Recruit.Vacancies.Client.Domain.Entities; using Esfa.Recruit.Vacancies.Client.Domain.Messaging; using Esfa.Recruit.Vacancies.Client.Infrastructure.Client; -using Esfa.Recruit.Vacancies.Client.Infrastructure.Services.PasAccount; using FluentAssertions; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; @@ -36,8 +31,7 @@ public async Task SubmitVacancyAsync_ShouldNotSubmitWhenMissingAgreements( var vacancyId = Guid.NewGuid(); 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,7 +39,7 @@ public async Task SubmitVacancyAsync_ShouldNotSubmitWhenMissingAgreements( vacancy.Status = VacancyStatus.Draft; vacancy.IsDeleted = false; vacancy.EmployerAccountId = employerAccountId; - vacancy.LegalEntityId = legalEntityId; + vacancy.AccountLegalEntityPublicHashedId = accountLegalEntityPublicHashedId; vacancy.OwnerType = OwnerType.Provider; var client = new Mock(); @@ -69,7 +63,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/QA/QA.Web/Mappings/ReviewMapper.cs b/src/QA/QA.Web/Mappings/ReviewMapper.cs index 5167953067..15a9edfcb8 100644 --- a/src/QA/QA.Web/Mappings/ReviewMapper.cs +++ b/src/QA/QA.Web/Mappings/ReviewMapper.cs @@ -141,7 +141,7 @@ public async Task Map(VacancyReview review) var reviewSummaryTask = _reviewSummaryService.GetReviewSummaryViewModelAsync(review.Id, ReviewFieldMappingLookups.GetPreviewReviewFieldIndicators()); - var anonymousApprovedCountTask = vacancy.IsAnonymous ? _vacancyClient.GetAnonymousApprovedCountAsync(vacancy.LegalEntityId) : Task.FromResult(0); + var anonymousApprovedCountTask = vacancy.IsAnonymous ? _vacancyClient.GetAnonymousApprovedCountAsync(vacancy.AccountLegalEntityPublicHashedId) : Task.FromResult(0); await Task.WhenAll( currentVacancy,programmeTask, 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..94c4e42ad0 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); } @@ -30,7 +30,7 @@ public async Task HasLegalEntityAgreementAsync(string employerAccountId, L return true; //Agreement may have been signed since the projection was created. Check Employer Service. - var hasLegalEntityAgreement = await CheckEmployerServiceForLegalEntityAgreementAsync(employerAccountId, legalEntity.LegalEntityId); + var hasLegalEntityAgreement = await CheckEmployerServiceForLegalEntityAgreementAsync(employerAccountId, legalEntity.AccountLegalEntityPublicHashedId); if (hasLegalEntityAgreement) { @@ -40,20 +40,20 @@ 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; } - private async Task CheckEmployerServiceForLegalEntityAgreementAsync(string employerAccountId, long legalEntityId) + private async Task CheckEmployerServiceForLegalEntityAgreementAsync(string employerAccountId, string accountLegalEntityPublicHashedId) { var legalEntities = await _client.GetEmployerLegalEntitiesAsync(employerAccountId); - var legalEntity = legalEntities.SingleOrDefault(e => e.LegalEntityId == legalEntityId); + var legalEntity = legalEntities.SingleOrDefault(e => e.AccountLegalEntityPublicHashedId == accountLegalEntityPublicHashedId); return legalEntity?.HasLegalEntityAgreement ?? false; } diff --git a/src/Shared/Recruit.Shared.Web/ViewModels/ValidationMessages.cs b/src/Shared/Recruit.Shared.Web/ViewModels/ValidationMessages.cs index 0d2206c7d1..81d5d1d130 100644 --- a/src/Shared/Recruit.Shared.Web/ViewModels/ValidationMessages.cs +++ b/src/Shared/Recruit.Shared.Web/ViewModels/ValidationMessages.cs @@ -42,7 +42,7 @@ public static class TypeOfMoney public static class DeleteVacancyConfirmationMessages { - public const string SelectionRequired = "You must select one option"; + public const string SelectionRequired = "Select yes if you want to delete this advert"; } public static class CloseVacancyConfirmationMessages diff --git a/src/Shared/Recruit.Vacancies.Client/Application/CommandHandlers/RefreshEmployerProfilesCommandHandler.cs b/src/Shared/Recruit.Vacancies.Client/Application/CommandHandlers/RefreshEmployerProfilesCommandHandler.cs index 50b6f91467..6bf3220f02 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,47 +17,50 @@ 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) + foreach (var accountLegalEntityPublicHashedId in message.AccountLegalEntityPublicHashedIds) { - if (!profiles.Any(x => x.LegalEntityId == legalEntity)) - { + var selectedOrganisation = + editVacancyInfo.LegalEntities.Single(l => l.AccountLegalEntityPublicHashedId == accountLegalEntityPublicHashedId); + if (!profiles.Any(x => x.AccountLegalEntityPublicHashedId == accountLegalEntityPublicHashedId)) + { var currentTime = _time.Now; // Create new profile var newProfile = new EmployerProfile { 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); + _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 06a095786e..fb6ffc1944 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 " + + "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 60e034ef67..f39e9a7195 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; @@ -8,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/Queues/Messages/TransferVacanciesFromProviderQueueMessage.cs b/src/Shared/Recruit.Vacancies.Client/Application/Queues/Messages/TransferVacanciesFromProviderQueueMessage.cs index 3cc9f86c14..4281351b87 100644 --- a/src/Shared/Recruit.Vacancies.Client/Application/Queues/Messages/TransferVacanciesFromProviderQueueMessage.cs +++ b/src/Shared/Recruit.Vacancies.Client/Application/Queues/Messages/TransferVacanciesFromProviderQueueMessage.cs @@ -7,7 +7,7 @@ public class TransferVacanciesFromProviderQueueMessage { public long Ukprn { get; set; } public string EmployerAccountId { get; set; } - public long LegalEntityId { get; set; } + public string AccountLegalEntityPublicHashedId { get; set; } public Guid UserRef { get; set; } public string UserEmailAddress { get; set; } public string UserName { 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/Application/Validation/Fluent/CustomValidators/VacancyValidators/VacancyFluentValidationExtensions.cs b/src/Shared/Recruit.Vacancies.Client/Application/Validation/Fluent/CustomValidators/VacancyValidators/VacancyFluentValidationExtensions.cs index 8d27269149..56aab642ca 100644 --- a/src/Shared/Recruit.Vacancies.Client/Application/Validation/Fluent/CustomValidators/VacancyValidators/VacancyFluentValidationExtensions.cs +++ b/src/Shared/Recruit.Vacancies.Client/Application/Validation/Fluent/CustomValidators/VacancyValidators/VacancyFluentValidationExtensions.cs @@ -126,7 +126,7 @@ internal static IRuleBuilderInitial TrainingProviderVacancyMus if (vacancy.OwnerType != OwnerType.Provider) return; - var hasPermission = await providerRelationshipService.HasProviderGotEmployersPermissionAsync(vacancy.TrainingProvider.Ukprn.Value, vacancy.EmployerAccountId, vacancy.LegalEntityId); + var hasPermission = await providerRelationshipService.HasProviderGotEmployersPermissionAsync(vacancy.TrainingProvider.Ukprn.Value, vacancy.EmployerAccountId, vacancy.AccountLegalEntityPublicHashedId); if (hasPermission) return; diff --git a/src/Shared/Recruit.Vacancies.Client/Domain/Entities/EmployerProfile.cs b/src/Shared/Recruit.Vacancies.Client/Domain/Entities/EmployerProfile.cs index 301bd8aefc..26d2bd2254 100644 --- a/src/Shared/Recruit.Vacancies.Client/Domain/Entities/EmployerProfile.cs +++ b/src/Shared/Recruit.Vacancies.Client/Domain/Entities/EmployerProfile.cs @@ -6,19 +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) + public string AccountLegalEntityPublicHashedId { get; set; } + public static string GetId(string employerAccountId, string accountLegalEntityPublicHashedId) { - return string.Format(IdFormat, employerAccountId, legalEntityId); + return string.Format(IdFormat, employerAccountId, accountLegalEntityPublicHashedId); } public IList
OtherLocations { get; set; } = new List
(); + } } diff --git a/src/Shared/Recruit.Vacancies.Client/Domain/Entities/Vacancy.cs b/src/Shared/Recruit.Vacancies.Client/Domain/Entities/Vacancy.cs index acdff20a20..5827c4fcd4 100644 --- a/src/Shared/Recruit.Vacancies.Client/Domain/Entities/Vacancy.cs +++ b/src/Shared/Recruit.Vacancies.Client/Domain/Entities/Vacancy.cs @@ -9,32 +9,24 @@ public class Vacancy public string EmployerAccountId { get; set; } public long? VacancyReference { get; set; } public VacancyStatus Status { get; set; } - public OwnerType OwnerType { get; set; } public SourceOrigin SourceOrigin { get; set; } public SourceType SourceType { get; set; } public long? SourceVacancyReference { get; set; } - public DateTime? ClosedDate { get; set; } public VacancyUser ClosedByUser { get; set; } - public DateTime? CreatedDate { get; set; } public VacancyUser CreatedByUser { get; set; } - public DateTime? SubmittedDate { get; set; } public VacancyUser SubmittedByUser { get; set; } - public DateTime? ApprovedDate { get; set; } - public DateTime? LiveDate { get; set; } public DateTime? LastUpdatedDate { get; set; } public VacancyUser LastUpdatedByUser { get; set; } - public bool IsDeleted { get; set; } public DateTime? DeletedDate { get; set; } public VacancyUser DeletedByUser { get; set; } - public string AnonymousReason { get; set; } public string ApplicationInstructions { get; set; } public ApplicationMethod? ApplicationMethod { get; set; } @@ -50,7 +42,6 @@ public class Vacancy public string LegalEntityName { get; set; } public string EmployerWebsiteUrl { get; set; } public GeoCodeMethod? GeoCodeMethod { get; set; } - public long LegalEntityId { get; set; } public string AccountLegalEntityPublicHashedId { get; set; } public int? NumberOfPositions { get; set; } public string OutcomeDescription { get; set; } @@ -68,27 +59,21 @@ public class Vacancy public ClosureReason? ClosureReason { get; set; } public string ClosureExplanation { get; set; } public TransferInfo TransferInfo { get; set; } - public bool CanClose => Status == VacancyStatus.Live; - public bool CanClone => Status == VacancyStatus.Live || Status == VacancyStatus.Closed || Status == VacancyStatus.Submitted; - - /// /// We can only delete draft vacancies that have not been deleted /// public bool CanDelete => (Status == VacancyStatus.Draft || Status == VacancyStatus.Referred) && IsDeleted == false; - /// /// We can only edit draft & referred vacancies that have not been deleted /// public bool CanEdit => (Status == VacancyStatus.Draft || Status == VacancyStatus.Referred ) && IsDeleted == false; - /// /// The vacancy is being edited /// We can only submit draft & referred vacancies that have not been deleted diff --git a/src/Shared/Recruit.Vacancies.Client/Domain/Events/ProviderBlockedOnLegalEntityEvent.cs b/src/Shared/Recruit.Vacancies.Client/Domain/Events/ProviderBlockedOnLegalEntityEvent.cs index 6b17f50c02..8273724597 100644 --- a/src/Shared/Recruit.Vacancies.Client/Domain/Events/ProviderBlockedOnLegalEntityEvent.cs +++ b/src/Shared/Recruit.Vacancies.Client/Domain/Events/ProviderBlockedOnLegalEntityEvent.cs @@ -7,7 +7,6 @@ public class ProviderBlockedOnLegalEntityEvent : EventBase, INotification { public long Ukprn { get; set; } public string EmployerAccountId { get; set; } - public long LegalEntityId { get; set; } public string AccountLegalEntityPublicHashedId { get; set; } } } \ No newline at end of file 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/Domain/Repositories/IVacancyQuery.cs b/src/Shared/Recruit.Vacancies.Client/Domain/Repositories/IVacancyQuery.cs index 855a2942eb..87e5823c09 100644 --- a/src/Shared/Recruit.Vacancies.Client/Domain/Repositories/IVacancyQuery.cs +++ b/src/Shared/Recruit.Vacancies.Client/Domain/Repositories/IVacancyQuery.cs @@ -19,8 +19,8 @@ public interface IVacancyQuery Task> GetAllVacancyReferencesAsync(); Task> GetAllVacancyIdsAsync(); Task> GetVacanciesAssociatedToProvider(long ukprn); - Task> GetProviderOwnedVacanciesForLegalEntityAsync(long ukprn, long legalEntityId); - Task> GetProviderOwnedVacanciesForEmployerWithoutLegalEntityAsync(long ukprn, string employerAccountId); + Task> GetProviderOwnedVacanciesForLegalEntityAsync(long ukprn, string accountLegalEntityPublicHashedId); + Task> GetProviderOwnedVacanciesForEmployerWithoutAccountLegalEntityPublicHashedIdAsync(long ukprn, string employerAccountId); Task> GetDraftVacanciesCreatedBeforeAsync(DateTime staleDate); Task> GetReferredVacanciesSubmittedBeforeAsync(DateTime staleDate); } diff --git a/src/Shared/Recruit.Vacancies.Client/Domain/Repositories/IVacancyReviewQuery.cs b/src/Shared/Recruit.Vacancies.Client/Domain/Repositories/IVacancyReviewQuery.cs index 5e65003f70..07a5ab0a88 100644 --- a/src/Shared/Recruit.Vacancies.Client/Domain/Repositories/IVacancyReviewQuery.cs +++ b/src/Shared/Recruit.Vacancies.Client/Domain/Repositories/IVacancyReviewQuery.cs @@ -16,6 +16,6 @@ public interface IVacancyReviewQuery Task GetApprovedFirstTimeCountAsync(string submittedByUserId); Task> GetAssignedForUserAsync(string userId, DateTime assignationExpiryDateTime); Task GetCurrentReferredVacancyReviewAsync(long vacancyReference); - Task GetAnonymousApprovedCountAsync(long legalEntityId); + Task GetAnonymousApprovedCountAsync(string accountLegalEntityPublicHashedId); } } \ No newline at end of file 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/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/IQaVacancyClient.cs b/src/Shared/Recruit.Vacancies.Client/Infrastructure/Client/IQaVacancyClient.cs index adfc4be068..158637d2cf 100644 --- a/src/Shared/Recruit.Vacancies.Client/Infrastructure/Client/IQaVacancyClient.cs +++ b/src/Shared/Recruit.Vacancies.Client/Infrastructure/Client/IQaVacancyClient.cs @@ -28,7 +28,7 @@ public interface IQaVacancyClient Task UnassignVacancyReviewAsync(Guid reviewId); Task GetCurrentReferredVacancyReviewAsync(long vacancyReference); Task> GetVacancyReviewHistoryAsync(long vacancyReference); - Task GetAnonymousApprovedCountAsync(long legalEntityId); + Task GetAnonymousApprovedCountAsync(string accountLegalEntityPublicHashedId); Task CreateApplicationsReportAsync(DateTime fromDate, DateTime toDate, VacancyUser user, string reportName); Task> GetReportsAsync(); Task GetReportAsync(Guid reportId); 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/QaVacancyClient.cs b/src/Shared/Recruit.Vacancies.Client/Infrastructure/Client/QaVacancyClient.cs index 041b0b07d1..04f48f1ad5 100644 --- a/src/Shared/Recruit.Vacancies.Client/Infrastructure/Client/QaVacancyClient.cs +++ b/src/Shared/Recruit.Vacancies.Client/Infrastructure/Client/QaVacancyClient.cs @@ -186,9 +186,9 @@ public async Task> GetVacancyReviewHistoryAsync(long vacancy .ToList(); } - public Task GetAnonymousApprovedCountAsync(long legalEntityId) + public Task GetAnonymousApprovedCountAsync(string accountLegalEntityPublicHashedId) { - return _vacancyReviewQuery.GetAnonymousApprovedCountAsync(legalEntityId); + return _vacancyReviewQuery.GetAnonymousApprovedCountAsync(accountLegalEntityPublicHashedId); } public async Task CreateApplicationsReportAsync(DateTime fromDate, DateTime toDate, VacancyUser user, string reportName) 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/QueryStore/Projections/EditVacancyInfo/LegalEntity.cs b/src/Shared/Recruit.Vacancies.Client/Infrastructure/QueryStore/Projections/EditVacancyInfo/LegalEntity.cs index da8ec4d659..1abbb21248 100644 --- a/src/Shared/Recruit.Vacancies.Client/Infrastructure/QueryStore/Projections/EditVacancyInfo/LegalEntity.cs +++ b/src/Shared/Recruit.Vacancies.Client/Infrastructure/QueryStore/Projections/EditVacancyInfo/LegalEntity.cs @@ -2,7 +2,6 @@ { public class LegalEntity { - public long LegalEntityId { get; set; } public string Name { get; set; } public Address Address { get; set; } public bool HasLegalEntityAgreement { get; set; } diff --git a/src/Shared/Recruit.Vacancies.Client/Infrastructure/QueryStore/Projections/VacancySummary/VacancySummary.cs b/src/Shared/Recruit.Vacancies.Client/Infrastructure/QueryStore/Projections/VacancySummary/VacancySummary.cs index b6a3022a1a..eeae05f9ad 100644 --- a/src/Shared/Recruit.Vacancies.Client/Infrastructure/QueryStore/Projections/VacancySummary/VacancySummary.cs +++ b/src/Shared/Recruit.Vacancies.Client/Infrastructure/QueryStore/Projections/VacancySummary/VacancySummary.cs @@ -8,7 +8,6 @@ public class VacancySummary public Guid Id { get; set; } public string Title { get; set; } public long? VacancyReference { get; set; } - public long? LegalEntityId { get; set; } public string LegalEntityName { get; set; } public string EmployerAccountId { get; set; } public string EmployerName { get; set; } diff --git a/src/Shared/Recruit.Vacancies.Client/Infrastructure/Repositories/MongoDbEmployerProfileRepository.cs b/src/Shared/Recruit.Vacancies.Client/Infrastructure/Repositories/MongoDbEmployerProfileRepository.cs index 9d908259c2..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,7 @@ 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/Recruit.Vacancies.Client/Infrastructure/Repositories/MongoDbVacancyRepository.cs b/src/Shared/Recruit.Vacancies.Client/Infrastructure/Repositories/MongoDbVacancyRepository.cs index ab6fb87224..4a64f06d8b 100644 --- a/src/Shared/Recruit.Vacancies.Client/Infrastructure/Repositories/MongoDbVacancyRepository.cs +++ b/src/Shared/Recruit.Vacancies.Client/Infrastructure/Repositories/MongoDbVacancyRepository.cs @@ -280,13 +280,13 @@ public async Task> GetVacanciesAssociatedToP return result; } - public async Task> GetProviderOwnedVacanciesForLegalEntityAsync(long ukprn, long legalEntityId) + public async Task> GetProviderOwnedVacanciesForLegalEntityAsync(long ukprn, string accountLegalEntityPublicHashedId) { var builder = Builders.Filter; var filter = builder.Eq(v => v.IsDeleted, false) & builder.Eq(v => v.OwnerType, OwnerType.Provider) & builder.Eq(v => v.TrainingProvider.Ukprn, ukprn) & - builder.Eq(v => v.LegalEntityId, legalEntityId); + builder.Eq(v => v.AccountLegalEntityPublicHashedId, accountLegalEntityPublicHashedId); var collection = GetCollection(); @@ -299,14 +299,14 @@ public async Task> GetProviderOwnedVacanciesForLegalEntityA return result; } - public async Task> GetProviderOwnedVacanciesForEmployerWithoutLegalEntityAsync(long ukprn, string employerAccountId) + public async Task> GetProviderOwnedVacanciesForEmployerWithoutAccountLegalEntityPublicHashedIdAsync(long ukprn, string employerAccountId) { var builder = Builders.Filter; var filter = builder.Eq(v => v.IsDeleted, false) & builder.Eq(v => v.OwnerType, OwnerType.Provider) & builder.Eq(v => v.TrainingProvider.Ukprn, ukprn) & builder.Eq(v => v.EmployerAccountId, employerAccountId) & - builder.Eq(v => v.LegalEntityId, 0); + builder.Eq(v => v.AccountLegalEntityPublicHashedId, "0"); var collection = GetCollection(); @@ -314,7 +314,7 @@ public async Task> GetProviderOwnedVacanciesForEmployerWith collection.Aggregate() .Match(filter) .ToListAsync(), - new Context(nameof(GetProviderOwnedVacanciesForEmployerWithoutLegalEntityAsync))); + new Context(nameof(GetProviderOwnedVacanciesForEmployerWithoutAccountLegalEntityPublicHashedIdAsync))); return result; } diff --git a/src/Shared/Recruit.Vacancies.Client/Infrastructure/Repositories/MongoDbVacancyReviewRepository.cs b/src/Shared/Recruit.Vacancies.Client/Infrastructure/Repositories/MongoDbVacancyReviewRepository.cs index 7efe095ec9..8ec7c34227 100644 --- a/src/Shared/Recruit.Vacancies.Client/Infrastructure/Repositories/MongoDbVacancyReviewRepository.cs +++ b/src/Shared/Recruit.Vacancies.Client/Infrastructure/Repositories/MongoDbVacancyReviewRepository.cs @@ -189,10 +189,10 @@ public async Task GetCurrentReferredVacancyReviewAsync(long vacan return vacancyReview; } - public async Task GetAnonymousApprovedCountAsync(long legalEntityId) + public async Task GetAnonymousApprovedCountAsync(string accountLegalEntityPublicHashedId) { var filterBuilder = Builders.Filter; - var filter = filterBuilder.Eq(r => r.VacancySnapshot.LegalEntityId, legalEntityId) & + var filter = filterBuilder.Eq(r => r.VacancySnapshot.AccountLegalEntityPublicHashedId, accountLegalEntityPublicHashedId) & filterBuilder.Eq(r => r.VacancySnapshot.EmployerNameOption, EmployerNameOption.Anonymous) & filterBuilder.Eq(r => r.Status, ReviewStatus.Closed) & filterBuilder.Eq(r => r.ManualOutcome, ManualQaOutcome.Approved); diff --git a/src/Shared/Recruit.Vacancies.Client/Infrastructure/Services/EmployerAccount/LegalEntityMapper.cs b/src/Shared/Recruit.Vacancies.Client/Infrastructure/Services/EmployerAccount/LegalEntityMapper.cs index e28e3b969f..b4f7232908 100644 --- a/src/Shared/Recruit.Vacancies.Client/Infrastructure/Services/EmployerAccount/LegalEntityMapper.cs +++ b/src/Shared/Recruit.Vacancies.Client/Infrastructure/Services/EmployerAccount/LegalEntityMapper.cs @@ -12,7 +12,6 @@ public static LegalEntity MapFromAccountApiLegalEntity(LegalEntityViewModel data { return new LegalEntity { - LegalEntityId = data.LegalEntityId, AccountLegalEntityPublicHashedId = data.AccountLegalEntityPublicHashedId, Name = data.Name, Address = MapFromAddressLine(data.Address), diff --git a/src/Shared/Recruit.Vacancies.Client/Infrastructure/Services/ProviderRelationship/IProviderRelationshipsService.cs b/src/Shared/Recruit.Vacancies.Client/Infrastructure/Services/ProviderRelationship/IProviderRelationshipsService.cs index 4d7ab2ca73..63e90e8d3a 100644 --- a/src/Shared/Recruit.Vacancies.Client/Infrastructure/Services/ProviderRelationship/IProviderRelationshipsService.cs +++ b/src/Shared/Recruit.Vacancies.Client/Infrastructure/Services/ProviderRelationship/IProviderRelationshipsService.cs @@ -7,7 +7,7 @@ namespace Esfa.Recruit.Vacancies.Client.Infrastructure.Services.ProviderRelation public interface IProviderRelationshipsService { Task> GetLegalEntitiesForProviderAsync(long ukprn); - Task HasProviderGotEmployersPermissionAsync(long ukprn, string accountPublicHashedId, long legalEntityId); + Task HasProviderGotEmployersPermissionAsync(long ukprn, string accountPublicHashedId, string accountLegalEntityPublicHashedId); Task RevokeProviderPermissionToRecruitAsync(long ukprn, string accountLegalEntityPublicHashedId); } } \ No newline at end of file diff --git a/src/Shared/Recruit.Vacancies.Client/Infrastructure/Services/ProviderRelationship/ProviderRelationshipsService.cs b/src/Shared/Recruit.Vacancies.Client/Infrastructure/Services/ProviderRelationship/ProviderRelationshipsService.cs index ab13879abc..6a0b503d40 100644 --- a/src/Shared/Recruit.Vacancies.Client/Infrastructure/Services/ProviderRelationship/ProviderRelationshipsService.cs +++ b/src/Shared/Recruit.Vacancies.Client/Infrastructure/Services/ProviderRelationship/ProviderRelationshipsService.cs @@ -41,7 +41,7 @@ public async Task> GetLegalEntitiesForProviderAsync(lo return await GetEmployerInfosAsync(providerPermissions); } - public async Task HasProviderGotEmployersPermissionAsync(long ukprn, string accountHashedId, long legalEntityId) + public async Task HasProviderGotEmployersPermissionAsync(long ukprn, string accountHashedId, string accountLegalEntityPublicHashedId) { var accountDetails = await _accountApiClient.GetAccount(accountHashedId); var permittedLegalEntities = await GetProviderPermissionsforEmployer(ukprn, accountDetails.PublicHashedAccountId); @@ -56,7 +56,7 @@ public async Task HasProviderGotEmployersPermissionAsync(long ukprn, strin ple => ple.AccountLegalEntityPublicHashedId, ale => ale.AccountLegalEntityPublicHashedId, (ple, ale) => ale) - .Any(l => l.LegalEntityId == legalEntityId); + .Any(l => l.AccountLegalEntityPublicHashedId == accountLegalEntityPublicHashedId); return hasPermission; } diff --git a/src/Shared/Recruit.Vacancies.Client/Infrastructure/Services/VacancySummariesProvider/VacancySummaryAggQueryBuilder.cs b/src/Shared/Recruit.Vacancies.Client/Infrastructure/Services/VacancySummariesProvider/VacancySummaryAggQueryBuilder.cs index c6bee9f964..577e62b34a 100644 --- a/src/Shared/Recruit.Vacancies.Client/Infrastructure/Services/VacancySummariesProvider/VacancySummaryAggQueryBuilder.cs +++ b/src/Shared/Recruit.Vacancies.Client/Infrastructure/Services/VacancySummariesProvider/VacancySummaryAggQueryBuilder.cs @@ -28,7 +28,6 @@ public static class VacancySummaryAggQueryBuilder 'title': 1, 'status': 1, 'appStatus': '$candidateApplicationReview.status', - 'legalEntityId': 1, 'legalEntityName': 1, 'employerAccountId': 1, 'employerName': 1, @@ -57,7 +56,6 @@ public static class VacancySummaryAggQueryBuilder 'title': 1, 'status': 1, 'appStatus': { '$cond' : [ { '$eq': ['$isApplicationWithdrawn', true] }, 'withdrawn', '$appStatus' ]}, - 'legalEntityId': 1, 'legalEntityName': 1, 'employerAccountId': 1, 'employerName': 1, @@ -84,7 +82,6 @@ public static class VacancySummaryAggQueryBuilder 'vacancyReference': 1, 'title': 1, 'status': 1, - 'legalEntityId': 1, 'legalEntityName': 1, 'employerAccountId': 1, 'employerName': 1, @@ -133,7 +130,6 @@ public static class VacancySummaryAggQueryBuilder 'vacancyReference': '$vacancyReference', 'title': '$title', 'status': '$status', - 'legalEntityId': '$legalEntityId', 'legalEntityName': '$legalEntityName', 'employerAccountId': '$employerAccountId', 'employerName': '$employerName', diff --git a/src/Shared/Recruit.Vacancies.Client/Infrastructure/Services/VacancySummariesProvider/VacancySummaryAggQueryResponseDto.cs b/src/Shared/Recruit.Vacancies.Client/Infrastructure/Services/VacancySummariesProvider/VacancySummaryAggQueryResponseDto.cs index 945db46d09..709f3af97c 100644 --- a/src/Shared/Recruit.Vacancies.Client/Infrastructure/Services/VacancySummariesProvider/VacancySummaryAggQueryResponseDto.cs +++ b/src/Shared/Recruit.Vacancies.Client/Infrastructure/Services/VacancySummariesProvider/VacancySummaryAggQueryResponseDto.cs @@ -16,7 +16,6 @@ internal class VacancySummaryDetails public Guid VacancyGuid { get; set; } public long? VacancyReference { get; set; } public string Title { get; set; } - public long? LegalEntityId { get; set; } public string LegalEntityName { get; set; } public string EmployerAccountId { get; set; } public string EmployerName { get; set; } diff --git a/src/Shared/Recruit.Vacancies.Client/Infrastructure/Services/VacancySummariesProvider/VacancySummaryMapper.cs b/src/Shared/Recruit.Vacancies.Client/Infrastructure/Services/VacancySummariesProvider/VacancySummaryMapper.cs index 50f7257574..97ce0e2c2b 100644 --- a/src/Shared/Recruit.Vacancies.Client/Infrastructure/Services/VacancySummariesProvider/VacancySummaryMapper.cs +++ b/src/Shared/Recruit.Vacancies.Client/Infrastructure/Services/VacancySummariesProvider/VacancySummaryMapper.cs @@ -13,7 +13,6 @@ internal static VacancySummary MapFromVacancySummaryAggQueryResponseDto(VacancyS Id = vacSummaryDetail.VacancyGuid, Title = vacSummaryDetail.Title, VacancyReference = vacSummaryDetail.VacancyReference, - LegalEntityId = vacSummaryDetail.LegalEntityId, LegalEntityName = vacSummaryDetail.LegalEntityName, EmployerAccountId = vacSummaryDetail.EmployerAccountId, EmployerName = vacSummaryDetail.EmployerName, diff --git a/src/Shared/UnitTests/Shared.Web/Services/LegalEntityAgreementServiceTests.cs b/src/Shared/UnitTests/Shared.Web/Services/LegalEntityAgreementServiceTests.cs index a31cc7d88d..6ad10e33c9 100644 --- a/src/Shared/UnitTests/Shared.Web/Services/LegalEntityAgreementServiceTests.cs +++ b/src/Shared/UnitTests/Shared.Web/Services/LegalEntityAgreementServiceTests.cs @@ -13,16 +13,15 @@ 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, true, "5678",true, "5678"); - 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 +30,9 @@ public async Task HasLegalEntityAgreementAsync_ShouldReturnFalseIfNoMatchingLega [Fact] public async Task HasLegalEntityAgreementAsync_ShouldNotCheckEmployerServiceWhenHasAgreement() { - var sut = GetLegalEntityAgreementService(EmployerAccountId, LegalEntityId, true, LegalEntityId, true); + var sut = GetLegalEntityAgreementService(EmployerAccountId, true, AccountLegalEntityPublicHashedId,true, AccountLegalEntityPublicHashedId); - 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 +41,9 @@ public async Task HasLegalEntityAgreementAsync_ShouldNotCheckEmployerServiceWhen [Fact] public async Task HasLegalEntityAgreementAsync_ShouldCheckEmployerServiceWhenHasNoAgreement() { - var sut = GetLegalEntityAgreementService(EmployerAccountId, LegalEntityId, false, LegalEntityId, true); + var sut = GetLegalEntityAgreementService(EmployerAccountId, false, AccountLegalEntityPublicHashedId,true, AccountLegalEntityPublicHashedId); - 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 +53,9 @@ public async Task HasLegalEntityAgreementAsync_ShouldCheckEmployerServiceWhenHas [Fact] public async Task HasLegalEntityAgreementAsync_ShouldReturnFalseWhenEmployerServiceLegalEntityHasNoAgreement() { - var sut = GetLegalEntityAgreementService(EmployerAccountId, LegalEntityId, false, LegalEntityId, false); + var sut = GetLegalEntityAgreementService(EmployerAccountId, false, AccountLegalEntityPublicHashedId,false, AccountLegalEntityPublicHashedId); - 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 +65,18 @@ public async Task HasLegalEntityAgreementAsync_ShouldReturnFalseWhenEmployerServ [Fact] public async Task HasLegalEntityAgreementAsync_ShouldReturnFalseWhenEmployerServiceCantLocateLegalEntity() { - var sut = GetLegalEntityAgreementService(EmployerAccountId, LegalEntityId, false, 5678, true); + var sut = GetLegalEntityAgreementService(EmployerAccountId, false, "5678",true, AccountLegalEntityPublicHashedId); - 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, bool hasLegalEntityAgreement, + string employerServiceAccountLegalEntityPublicHashedId, bool employerServiceHasLegalEntityAgreement, + string accountLegalEntityPublicHashedId) { _clientMock = new Mock(); _clientMock.Setup(c => c.GetEditVacancyInfoAsync(employerAccountId)).Returns(Task.FromResult( @@ -83,7 +84,11 @@ private LegalEntityAgreementService GetLegalEntityAgreementService(string employ { LegalEntities = new List { - new LegalEntity{LegalEntityId = legalEntityId, HasLegalEntityAgreement = hasLegalEntityAgreement} + new LegalEntity + { + AccountLegalEntityPublicHashedId = accountLegalEntityPublicHashedId, + HasLegalEntityAgreement = hasLegalEntityAgreement + } } })); @@ -92,8 +97,8 @@ private LegalEntityAgreementService GetLegalEntityAgreementService(string employ { new LegalEntity { - LegalEntityId = employerServiceLegalEntityId, - HasLegalEntityAgreement = employerServiceHasLegalEntityAgreement + AccountLegalEntityPublicHashedId = employerServiceAccountLegalEntityPublicHashedId, + HasLegalEntityAgreement = employerServiceHasLegalEntityAgreement } } .AsEnumerable())); diff --git a/src/Shared/UnitTests/Vacancies.Client/Application/CommandHandlers/CloneVacancyCommandHandlerTests.cs b/src/Shared/UnitTests/Vacancies.Client/Application/CommandHandlers/CloneVacancyCommandHandlerTests.cs index d884baab28..2d8c5aad26 100644 --- a/src/Shared/UnitTests/Vacancies.Client/Application/CommandHandlers/CloneVacancyCommandHandlerTests.cs +++ b/src/Shared/UnitTests/Vacancies.Client/Application/CommandHandlers/CloneVacancyCommandHandlerTests.cs @@ -109,7 +109,6 @@ private static void AssertKnownProperties(Vacancy original, Vacancy clone) {nameof(Vacancy.LegalEntityName), (o, c, s) => AssertProperty(o, c, s, CloneAssertType.Cloned)}, {nameof(Vacancy.EmployerWebsiteUrl), (o, c, s) => AssertProperty(o, c, s, CloneAssertType.Cloned)}, {nameof(Vacancy.GeoCodeMethod), (o, c, s) => AssertProperty(o, c, s, CloneAssertType.Cloned)}, - {nameof(Vacancy.LegalEntityId), (o, c, s) => AssertProperty(o, c, s, CloneAssertType.Cloned)}, {nameof(Vacancy.NumberOfPositions), (o, c, s) => AssertProperty(o, c, s, CloneAssertType.Cloned)}, {nameof(Vacancy.OutcomeDescription), (o, c, s) => AssertProperty(o, c, s, CloneAssertType.Cloned)}, {nameof(Vacancy.ProviderContact), (o, c, s) => AssertProperty(o, c, s, CloneAssertType.Cloned)}, 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(); diff --git a/src/Shared/UnitTests/Vacancies.Client/Application/VacancyValidation/SingleField/TrainingProviderUkprnValidationTests.cs b/src/Shared/UnitTests/Vacancies.Client/Application/VacancyValidation/SingleField/TrainingProviderUkprnValidationTests.cs index 3ee1a22f4b..5eb9023153 100644 --- a/src/Shared/UnitTests/Vacancies.Client/Application/VacancyValidation/SingleField/TrainingProviderUkprnValidationTests.cs +++ b/src/Shared/UnitTests/Vacancies.Client/Application/VacancyValidation/SingleField/TrainingProviderUkprnValidationTests.cs @@ -1,12 +1,11 @@ -using System.Collections.Generic; +using Esfa.Recruit.UnitTests.Vacancies.Client.Application.VacancyValidation; using Esfa.Recruit.Vacancies.Client.Application.Validation; using Esfa.Recruit.Vacancies.Client.Domain.Entities; -using Esfa.Recruit.Vacancies.Client.Infrastructure.QueryStore.Projections.EditVacancyInfo; using FluentAssertions; using Moq; using Xunit; -namespace Esfa.Recruit.UnitTests.Vacancies.Client.Application.VacancyValidation.SingleField +namespace Esfa.Recruit.Vacancies.Client.UnitTests.Vacancies.Client.Application.VacancyValidation.SingleField { public class TrainingProviderUkprnValidationTests : VacancyValidationTestsBase { @@ -123,19 +122,19 @@ public void ErrorIfProviderVacancyDoesNotHaveEmployerPermission() { const long ukprn = 12345678; const string employerAccountId = "employer-account-id"; - const long legalEntityId = 1234; + const string accountLegalEntityPublicHashedId = "1234"; var vacancy = new Vacancy { OwnerType = OwnerType.Provider, TrainingProvider = new TrainingProvider { Ukprn = ukprn }, EmployerAccountId = employerAccountId, - LegalEntityId = legalEntityId + AccountLegalEntityPublicHashedId = accountLegalEntityPublicHashedId }; MockTrainingProviderSummaryProvider.Setup(p => p.GetAsync(ukprn)).ReturnsAsync(new TrainingProviderSummary()); - MockProviderRelationshipsService.Setup(p => p.HasProviderGotEmployersPermissionAsync(ukprn, employerAccountId, legalEntityId)) + MockProviderRelationshipsService.Setup(p => p.HasProviderGotEmployersPermissionAsync(ukprn, employerAccountId, accountLegalEntityPublicHashedId)) .ReturnsAsync(false); var result = Validator.Validate(vacancy, VacancyRuleSet.TrainingProvider); @@ -152,19 +151,19 @@ public void ShouldNotErrorIfProviderVacancyHasEmployerPermission() { const long ukprn = 12345678; const string employerAccountId = "employer-account-id"; - const long legalEntityId = 1234; + const string accountLegalEntityPublicHashedId = "1234"; var vacancy = new Vacancy { OwnerType = OwnerType.Provider, TrainingProvider = new TrainingProvider { Ukprn = ukprn }, EmployerAccountId = employerAccountId, - LegalEntityId = legalEntityId + AccountLegalEntityPublicHashedId = accountLegalEntityPublicHashedId }; MockTrainingProviderSummaryProvider.Setup(p => p.GetAsync(ukprn)).ReturnsAsync(new TrainingProviderSummary()); - MockProviderRelationshipsService.Setup(p => p.HasProviderGotEmployersPermissionAsync(ukprn, employerAccountId, legalEntityId)) + MockProviderRelationshipsService.Setup(p => p.HasProviderGotEmployersPermissionAsync(ukprn, employerAccountId, accountLegalEntityPublicHashedId)) .ReturnsAsync(true); var result = Validator.Validate(vacancy, VacancyRuleSet.TrainingProvider); diff --git a/src/Shared/UnitTests/Vacancies.Client/Infrastructure/EventHandlers/VacancyClosedEventHandlerTests.cs b/src/Shared/UnitTests/Vacancies.Client/Infrastructure/EventHandlers/VacancyClosedEventHandlerTests.cs index 1a2c23d37f..20dbe3f801 100644 --- a/src/Shared/UnitTests/Vacancies.Client/Infrastructure/EventHandlers/VacancyClosedEventHandlerTests.cs +++ b/src/Shared/UnitTests/Vacancies.Client/Infrastructure/EventHandlers/VacancyClosedEventHandlerTests.cs @@ -74,7 +74,7 @@ public VacancyClosedEventHandlerTests() _vacancy = new Vacancy { Id = Guid.NewGuid(), - LegalEntityId = 299792458, + AccountLegalEntityPublicHashedId = "299792458", ProgrammeId = "42", EmployerLocation = new Address(), Qualifications = new List(),