public void Arrange() { var autoFixture = new Fixture(); _employerAccountsService = new Mock <IEmployerAccountsService>(); _chooseOrganisationRequest = autoFixture.Create <SelectLegalEntityRequest>(); var legalEntity = autoFixture.Create <LegalEntity>(); _employerAccountsService.Setup(x => x.GetLegalEntitiesForAccount(_chooseOrganisationRequest.AccountHashedId)) .ReturnsAsync(new List <LegalEntity> { legalEntity }); _mapper = new SelectLegalEntityRequestToSelectLegalEntityViewModelMapper(_employerAccountsService.Object); }
public void Arrange() { var autoFixture = new Fixture(); _modelMapper = new Mock <IModelMapper>(); _linkGenerator = new Mock <ILinkGenerator>(); _chooseOrganisationRequest = autoFixture.Create <SelectLegalEntityRequest>(); _selectLegalEntityViewModel = autoFixture.Create <SelectLegalEntityViewModel>(); _modelMapper.Setup(x => x.Map <SelectLegalEntityViewModel>(It.Is <SelectLegalEntityRequest>(r => r == _chooseOrganisationRequest))) .ReturnsAsync(_selectLegalEntityViewModel); _controller = new CohortController(Mock.Of <ICommitmentsApiClient>(), Mock.Of <ILogger <CohortController> >(), _linkGenerator.Object, _modelMapper.Object, Mock.Of <IAuthorizationService>(), Mock.Of <IEncodingService>()); }
public async Task <IActionResult> SelectLegalEntity(SelectLegalEntityRequest request) { var response = await _modelMapper.Map <SelectLegalEntityViewModel>(request); if (response.LegalEntities == null || !response.LegalEntities.Any()) { throw new Exception($"No legal entities associated with account {request.AccountHashedId}"); } if (response.LegalEntities.Count() > 1) { return(View(response)); } var autoSelectLegalEntity = response.LegalEntities.First(); var hasSignedMinimumRequiredAgreementVersion = autoSelectLegalEntity.HasSignedMinimumRequiredAgreementVersion(!string.IsNullOrWhiteSpace(request.transferConnectionCode)); if (hasSignedMinimumRequiredAgreementVersion) { return(RedirectToAction("SelectProvider", new SelectProviderRequest { AccountHashedId = request.AccountHashedId, TransferSenderId = request.transferConnectionCode, AccountLegalEntityId = autoSelectLegalEntity.Id, AccountLegalEntityHashedId = autoSelectLegalEntity.AccountLegalEntityPublicHashedId, EncodedPledgeApplicationId = request.EncodedPledgeApplicationId })); } return(RedirectToAction("AgreementNotSigned", new LegalEntitySignedAgreementViewModel { AccountHashedId = request.AccountHashedId, LegalEntityId = autoSelectLegalEntity.Id, CohortRef = request.cohortRef, LegalEntityName = autoSelectLegalEntity.Name, TransferConnectionCode = request.transferConnectionCode, AccountLegalEntityPublicHashedId = autoSelectLegalEntity.AccountLegalEntityPublicHashedId })); }