Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ER-1464_Show legal entity name #834

Merged
merged 3 commits into from
Sep 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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