Skip to content

Commit

Permalink
CON-1638-changes-after-initial-comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephek committed Apr 22, 2020
1 parent aac9180 commit e242f41
Showing 3 changed files with 24 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -23,7 +23,6 @@ namespace SFA.DAS.EmployerAccounts.Web.Controllers
public class EmployerTeamController : BaseController
{
private readonly EmployerTeamOrchestrator _employerTeamOrchestrator;
private readonly IAccountOrchestrator _accountOrchestrator;
private readonly IAuthorizationService _authorizationService;

public EmployerTeamController(
@@ -38,13 +37,11 @@ public EmployerTeamController(
IMultiVariantTestingService multiVariantTestingService,
ICookieStorageService<FlashMessageViewModel> flashMessage,
EmployerTeamOrchestrator employerTeamOrchestrator,
IAuthorizationService authorizationService,
IAccountOrchestrator accountOrchestrator)
IAuthorizationService authorizationService)
: base(owinWrapper, multiVariantTestingService, flashMessage)
{
_employerTeamOrchestrator = employerTeamOrchestrator;
_authorizationService = authorizationService;
_accountOrchestrator = accountOrchestrator;
}

[HttpGet]
@@ -623,7 +620,7 @@ public ActionResult OtherTasksPanel(AccountDashboardViewModel model)
private async Task<OrchestratorResponse<AccountDashboardViewModel>> GetAccountInformation(string hashedAccountId)
{
var externalUserId = OwinWrapper.GetClaimValue(ControllerConstants.UserRefClaimKeyName);
var response = await _accountOrchestrator.GetAccount(hashedAccountId, externalUserId);
var response = await _employerTeamOrchestrator.GetAccount(hashedAccountId, externalUserId);

var flashMessage = GetFlashMessageViewModelFromCookie();

Original file line number Diff line number Diff line change
@@ -35,8 +35,8 @@ public DefaultRegistry()

For<IDefaultAuthorizationHandler>().Use<Authorization.DefaultAuthorizationHandler>();

For<IAccountOrchestrator>().Use(c => c.GetInstance<EmployerTeamOrchestrator>());
For<IAccountOrchestrator>().DecorateAllWith<EmployerTeamOrchestratorWithCallToAction>();
//For<IEmployerTeamOrchestrator>().Use(c => c.GetInstance<EmployerTeamOrchestrator>());
For<EmployerTeamOrchestrator>().DecorateAllWith<EmployerTeamOrchestratorWithCallToAction>();
}
}

Original file line number Diff line number Diff line change
@@ -39,41 +39,41 @@
using SFA.DAS.Common.Domain.Types;

namespace SFA.DAS.EmployerAccounts.Web.Orchestrators
{
public interface IAccountOrchestrator
{
Task<OrchestratorResponse<AccountDashboardViewModel>> GetAccount(string hashedAccountId, string externalUserId);
}
{

public class AccountContext
{
public string HashedAccountId { get; set; }
public ApprenticeshipEmployerType ApprenticeshipEmployerType { get; set; }
}

public class EmployerTeamOrchestratorWithCallToAction : IAccountOrchestrator
public class EmployerTeamOrchestratorWithCallToAction : EmployerTeamOrchestrator
{
private const string AccountContextCookieName = "sfa-das-employerapprenticeshipsservice-accountcontext";
private readonly IAccountOrchestrator _accountOrchestrator;
private readonly EmployerTeamOrchestrator _employerTeamOrchestrator;
private readonly ICookieStorageService<AccountContext> _accountContext;
private readonly IMediator _mediator;
private readonly IMapper _mapper;

public EmployerTeamOrchestratorWithCallToAction(
IAccountOrchestrator accountOrchestrator,
ICookieStorageService<AccountContext> accountContext,
EmployerTeamOrchestrator employerTeamOrchestrator,
IMediator mediator,
IMapper mapper)
ICurrentDateTime currentDateTime,
IAccountApiClient accountApiClient,
IMapper mapper,
IAuthorizationService authorizationService,
ICookieStorageService<AccountContext> accountContext)
: base(mediator, currentDateTime, accountApiClient, mapper, authorizationService)
{
_accountOrchestrator = accountOrchestrator;
_employerTeamOrchestrator = employerTeamOrchestrator;
_accountContext = accountContext;
_mediator = mediator;
_mapper = mapper;
}

public async Task<OrchestratorResponse<AccountDashboardViewModel>> GetAccount(string hashedAccountId, string externalUserId)
public override async Task<OrchestratorResponse<AccountDashboardViewModel>> GetAccount(string hashedAccountId, string externalUserId)
{
var accountResponseTask = _accountOrchestrator.GetAccount(hashedAccountId, externalUserId);
var accountResponseTask = _employerTeamOrchestrator.GetAccount(hashedAccountId, externalUserId);

if (TryGetAccountContext(hashedAccountId, out AccountContext accountContext))
{
@@ -214,7 +214,7 @@ private async Task<OrchestratorResponse<CallToActionViewModel>> GetCallToAction(
}
}

public class EmployerTeamOrchestrator : UserVerificationOrchestratorBase, IAccountOrchestrator
public class EmployerTeamOrchestrator : UserVerificationOrchestratorBase
{
private readonly IMediator _mediator;
private readonly ICurrentDateTime _currentDateTime;
@@ -401,8 +401,7 @@ public virtual async Task<OrchestratorResponse<AccountDashboardViewModel>> GetAc
SignedAgreementCount = agreementsResponse.EmployerAgreements.Count(x => x.HasSignedAgreement),
PendingAgreements = pendingAgreements,
ApprenticeshipEmployerType = apprenticeshipEmployerType,
AgreementInfo = _mapper.Map<AccountDetailViewModel, AgreementInfoViewModel>(accountDetailViewModel),
CallToActionViewModel = new CallToActionViewModel()
AgreementInfo = _mapper.Map<AccountDetailViewModel, AgreementInfoViewModel>(accountDetailViewModel)
};

//note: ApprenticeshipEmployerType is already returned by GetEmployerAccountHashedQuery, but we need to transition to calling the api instead.
@@ -797,6 +796,11 @@ public virtual async Task<OrchestratorResponse<AccountSummaryViewModel>> GetAcco

public void GetCallToActionViewName(PanelViewModel<AccountDashboardViewModel> viewModel)
{
if(viewModel.Data.CallToActionViewModel == null)
{
return;
}

var rules = new Dictionary<int, EvalutateCallToActionRuleDelegate>();
rules.Add(100, EvalutateSignAgreementCallToActionRule);
rules.Add(101, vm => vm.Data.CallToActionViewModel.UnableToDetermineCallToAction);

0 comments on commit e242f41

Please sign in to comment.