public void ThenViewModelContainsControllerName(EmployerSelectionAction action, string controllerName)
        {
            var result = _selectEmployerMapper.Map(_listOfLegalEntities, action);

            Assert.IsNotNull(result);
            Assert.AreEqual(controllerName, result.ControllerName);
        }
        public async Task ThenProviderRelationshipResponseIsMapped(EmployerSelectionAction action)
        {
            await _orchestrator.GetChooseEmployerViewModel(1, action);

            _selectEmployerMapper.Verify(x =>
                                         x.Map(It.Is <IEnumerable <AccountProviderLegalEntityDto> >(r =>
                                                                                                    r.Equals(_permissionsResponse.ProviderRelationships)), It.Is <EmployerSelectionAction>(r => r == action)));
        }
        public void ThenLegalEntitiesAreMappedToViewModel(EmployerSelectionAction action)
        {
            var result = _selectEmployerMapper.Map(_listOfLegalEntities, action);

            Assert.IsNotNull(result);
            Assert.AreEqual(2, result.LegalEntities.Count());
            Assert.AreEqual(_legalEntity1.AccountPublicHashedId, result.LegalEntities.First().EmployerAccountPublicHashedId);
            Assert.AreEqual(_legalEntity1.AccountName, result.LegalEntities.First().EmployerAccountName);
            Assert.AreEqual(_legalEntity1.AccountLegalEntityPublicHashedId, result.LegalEntities.First().EmployerAccountLegalEntityPublicHashedId);
            Assert.AreEqual(_legalEntity1.AccountLegalEntityName, result.LegalEntities.First().EmployerAccountLegalEntityName);
            Assert.AreEqual(action, result.EmployerSelectionAction);
        }
        public ChooseEmployerViewModel Map(IEnumerable <AccountProviderLegalEntityDto> source, EmployerSelectionAction action)
        {
            var result = new ChooseEmployerViewModel();

            var legalEntities = new List <LegalEntityViewModel>();

            foreach (var relationship in source)
            {
                legalEntities.Add(new LegalEntityViewModel
                {
                    EmployerAccountPublicHashedId            = relationship.AccountPublicHashedId,
                    EmployerAccountName                      = relationship.AccountName,
                    EmployerAccountLegalEntityPublicHashedId = relationship.AccountLegalEntityPublicHashedId,
                    EmployerAccountLegalEntityName           = relationship.AccountLegalEntityName
                });
            }

            result.LegalEntities           = legalEntities;
            result.EmployerSelectionAction = action;

            switch (action)
            {
            case EmployerSelectionAction.CreateCohort:
                result.ControllerName = "CreateCohort";
                result.Title          = "Create Cohort";
                result.Description    = "Choose an employer you want to create a new cohort on behalf of.";
                break;

            case EmployerSelectionAction.CreateReservation:
                result.ControllerName = "Reservation";
                result.Title          = "Reserve Funds";
                result.Description    = "Choose an employer you want to reserve funds on behalf of.";
                break;
            }

            return(result);
        }
        public async Task <ChooseEmployerViewModel> GetChooseEmployerViewModel(long providerId, EmployerSelectionAction action)
        {
            Logger.Info($"Getting choose employer view model", providerId);

            var relationshipsWithPermission = await Mediator.Send(new GetProviderRelationshipsWithPermissionQueryRequest
            {
                ProviderId = providerId,
                Permission = Operation.CreateCohort
            });

            var result = _selectEmployerMapper.Map(relationshipsWithPermission.ProviderRelationships, action);

            return(result);
        }