public void ThenTheRequestFeatureToggleIsReturned()
        {
            //Arrange
            _booleanToggleValueProvider.Setup(x => x.EvaluateBooleanToggleValue(It.IsAny <IFeatureToggle>()))
            .Returns(true);

            //Act
            var flag = _featureToggleService.Get <DummyFeatureToggle>();

            //Assert
            Assert.IsNotNull(flag);
            Assert.IsInstanceOf <DummyFeatureToggle>(flag);
        }
        public async Task <AccountHomeViewModel> GetAccountHomeViewModel(int providerId)
        {
            try
            {
                _logger.Info($"Getting provider {providerId}");

                var providerResponse = await _mediator.Send(new GetProviderQueryRequest { UKPRN = providerId });

                var showCreateCohortLink = await ProviderHasPermission(providerId, Operation.CreateCohort);

                return(new AccountHomeViewModel
                {
                    AccountStatus = AccountStatus.Active,
                    ProviderName = providerResponse.ProvidersView.Provider.ProviderName,
                    ProviderId = providerId,
                    ShowAcademicYearBanner = false,
                    ShowCreateCohortLink = showCreateCohortLink,
                    ShowEmployerDemandLink = _featureToggleService.Get <EmployerDemand>().FeatureEnabled
                });
            }
            catch (Exception)
            {
                _logger.Warn($"Provider {providerId} details not found in provider information service");

                return(new AccountHomeViewModel {
                    AccountStatus = AccountStatus.NoAgreement
                });
            }
        }
 public async Task <FeatureToggleResponse> Get(string flagName, string userKey, bool defaultValue = default)
 {
     try
     {
         return(await _service.Get(flagName, userKey, defaultValue));
     }
     catch (Exception ex)
     {
         return(HandleException(ex, flagName, userKey, defaultValue));
     }
 }
 private string GetChangeOfProviderLink(string hashedAccountId, string hashedApprenticeshipId)
 {
     if (_featureToggleService.Get <ChangeOfProvider>().FeatureEnabled)
     {
         return(_linkGenerator.CommitmentsV2Link($"{hashedAccountId}/apprentices/{hashedApprenticeshipId}/change-provider"));
     }
     else
     {
         return(String.Empty);
     }
 }
예제 #5
0
        public async Task <ActionResult> Create(long providerId)
        {
            if (_featureToggleService.Get <ProviderCreateCohortV2>().FeatureEnabled)
            {
                return(Redirect(_providerUrlhelper.ProviderCommitmentsLink($"{providerId}/unapproved/add/select-employer")));
            }

            var model = await _selectEmployerOrchestrator.GetChooseEmployerViewModel(providerId, EmployerSelectionAction.CreateCohort);

            return(View("ChooseEmployer", model));
        }
        private bool EnsureOnlyTheApproveOptionIsValid(bool?x)
        {
            var rejection = _featureToggleService.Get <TransfersRejectOption>();

            if (rejection.FeatureEnabled)
            {
                return(true);
            }

            if (x == null)
            {
                return(true);
            }
            return(x.Value);
        }
        public async Task <ActionResult> YourCohorts(string hashedAccountId)
        {
            if (_featureToggleService.Get <EnhancedApprovals>().FeatureEnabled)
            {
                return(Redirect(_linkGenerator.CommitmentsV2Link($"{hashedAccountId}/unapproved")));
            }

            // otherwise call existing code
            if (!await IsUserRoleAuthorized(hashedAccountId, Role.Owner, Role.Transactor))
            {
                return(View("AccessDenied"));
            }

            var model = await Orchestrator.GetYourCohorts(hashedAccountId, OwinWrapper.GetClaimValue(@"sub"));

            SetFlashMessageOnModel(model);
            return(View(model));
        }
 public TransferRequestViewModel MapToTransferRequestViewModel(TransferRequest transferRequest)
 {
     return(new TransferRequestViewModel()
     {
         HashedTransferReceiverAccountId = _hashingService.HashValue(transferRequest.ReceivingEmployerAccountId),
         PublicHashedTransferReceiverAccountId = _publicHashingService.HashValue(transferRequest.ReceivingEmployerAccountId),
         HashedTransferSenderAccountId = _hashingService.HashValue(transferRequest.SendingEmployerAccountId),
         TransferSenderName = transferRequest.TransferSenderName,
         PublicHashedTransferSenderAccountId = _publicHashingService.HashValue(transferRequest.SendingEmployerAccountId),
         LegalEntityName = transferRequest.LegalEntityName,
         HashedCohortReference = _hashingService.HashValue(transferRequest.CommitmentId),
         TrainingList = transferRequest.TrainingList?.Select(MapTrainingCourse).ToList() ?? new List <TrainingCourseSummaryViewModel>(),
         TransferApprovalStatusDesc = transferRequest.Status.ToString(),
         TransferApprovalStatus = transferRequest.Status,
         TransferApprovalSetBy = transferRequest.ApprovedOrRejectedByUserName,
         TransferApprovalSetOn = transferRequest.ApprovedOrRejectedOn,
         TotalCost = transferRequest.TransferCost,
         FundingCap = transferRequest.FundingCap,
         EnableRejection = _featureToggleService.Get <TransfersRejectOption>().FeatureEnabled,
         ShowFundingCapWarning = (transferRequest.Status == TransferApprovalStatus.Pending ||
                                  transferRequest.Status == TransferApprovalStatus.Approved) &&
                                 transferRequest.TransferCost < transferRequest.FundingCap
     });
 }
 public async Task <ActionResult <IEnumerable <FeatureToggleViewModel> > > Get()
 {
     return(Ok(await _service.Get()));
 }