Skip to content

Commit

Permalink
ER-1464_Show legal entity name (#834) +semver: patch
Browse files Browse the repository at this point in the history
  • Loading branch information
shomavg authored Sep 26, 2019
1 parent e3a2138 commit 7bcf07b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Esfa.Recruit.Employer.Web.ViewModels.LegalEntityAgreement;
using Esfa.Recruit.Shared.Web.Services;
using Esfa.Recruit.Vacancies.Client.Infrastructure.Client;
using Esfa.Recruit.Vacancies.Client.Infrastructure.QueryStore.Projections.EditVacancyInfo;

namespace Esfa.Recruit.Employer.Web.Orchestrators
{
Expand Down Expand Up @@ -31,13 +32,18 @@ public async Task<LegalEntityAgreementSoftStopViewModel> GetLegalEntityAgreement
_client, _vacancyClient, vrm, RouteNames.LegalEntityAgreement_SoftStop_Get);

var legalEntityId = selectedLegalEntityId.HasValue ? selectedLegalEntityId.Value : vacancy.LegalEntityId;

LegalEntity legalEntity = await
_legalEntityAgreementService.GetLegalEntityAsync(vrm.EmployerAccountId, legalEntityId);

var hasLegalEntityAgreement = await
_legalEntityAgreementService.HasLegalEntityAgreementAsync(
vacancy.EmployerAccountId, legalEntity);

return new LegalEntityAgreementSoftStopViewModel
{
HasLegalEntityAgreement =
await _legalEntityAgreementService.HasLegalEntityAgreementAsync(
vacancy.EmployerAccountId, legalEntityId),
LegalEntityName = vacancy.LegalEntityName,
HasLegalEntityAgreement = hasLegalEntityAgreement,
LegalEntityName = legalEntity.Name,
PageInfo = Utility.GetPartOnePageInfo(vacancy)
};
}
Expand All @@ -50,7 +56,7 @@ public async Task<LegalEntityAgreementHardStopViewModel> GetLegalEntityAgreement
return new LegalEntityAgreementHardStopViewModel
{
HasLegalEntityAgreement = await _legalEntityAgreementService.HasLegalEntityAgreementAsync(
vacancy.EmployerAccountId, vacancy.LegalEntityId),
vacancy.EmployerAccountId, vacancy.LegalEntityId)
};
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
using System.Threading.Tasks;
using Esfa.Recruit.Vacancies.Client.Infrastructure.QueryStore.Projections.EditVacancyInfo;


namespace Esfa.Recruit.Shared.Web.Services
{
public interface ILegalEntityAgreementService
{
Task<bool> HasLegalEntityAgreementAsync(string employerAccountId, long legalEntityId);
Task<LegalEntity> GetLegalEntityAsync(string employerAccountId, long legalEntityId);
Task<bool> HasLegalEntityAgreementAsync(string employerAccountId, LegalEntity legalEntity);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@ public async Task<bool> HasLegalEntityAgreementAsync(string employerAccountId, l
{
var legalEntity = await GetLegalEntityAsync(employerAccountId, legalEntityId);

if(legalEntity == null)
return await HasLegalEntityAgreementAsync(employerAccountId, legalEntity);
}

public async Task<bool> HasLegalEntityAgreementAsync(string employerAccountId, LegalEntity legalEntity)
{
if (legalEntity == null)
return false;

if (legalEntity.HasLegalEntityAgreement)
return true;

Expand All @@ -35,7 +40,7 @@ public async Task<bool> HasLegalEntityAgreementAsync(string employerAccountId, l
return hasLegalEntityAgreement;
}

private async Task<LegalEntity> GetLegalEntityAsync(string employerAccountId, long legalEntityId)
public async Task<LegalEntity> GetLegalEntityAsync(string employerAccountId, long legalEntityId)
{
var employerData = await _client.GetEditVacancyInfoAsync(employerAccountId);

Expand All @@ -44,7 +49,7 @@ private async Task<LegalEntity> GetLegalEntityAsync(string employerAccountId, lo
return legalEntity;
}

private async Task<bool> CheckEmployerServiceForLegalEntityAgreementAsync(string employerAccountId, long legalEntityId)
private async Task<bool> CheckEmployerServiceForLegalEntityAgreementAsync(string employerAccountId, long legalEntityId)
{
var legalEntities = await _client.GetEmployerLegalEntitiesAsync(employerAccountId);

Expand Down

0 comments on commit 7bcf07b

Please sign in to comment.