Esempio n. 1
0
 public async Task <GetAccountProviderLegalEntitiesWithPermissionResponse> GetAccountProviderLegalEntitiesWithPermission(
     GetAccountProviderLegalEntitiesWithPermissionRequest request,
     CancellationToken cancellationToken = new CancellationToken())
 {
     return(new GetAccountProviderLegalEntitiesWithPermissionResponse
     {
         AccountProviderLegalEntities = await GetPermissionsForProvider(request.Ukprn, request.Operation, cancellationToken).ConfigureAwait(false)
     });
 }
        public Task <GetAccountProviderLegalEntitiesWithPermissionResponse> GetAccountProviderLegalEntitiesWithPermission()
        {
            GetAccountProviderLegalEntitiesWithPermissionRequest = new GetAccountProviderLegalEntitiesWithPermissionRequest
            {
                Ukprn     = 11111111,
                Operation = Operation.CreateCohort
            };

            return(ProviderRelationshipsApiClient.GetAccountProviderLegalEntitiesWithPermission(GetAccountProviderLegalEntitiesWithPermissionRequest, CancellationToken));
        }
        public async Task Run()
        {
            const long ukprn = 10005077;

            var relationshipsRequest = new GetAccountProviderLegalEntitiesWithPermissionRequest {
                Ukprn = ukprn, Operation = Operation.CreateCohort
            };
            var response = await _providerRelationshipsApiClient.GetAccountProviderLegalEntitiesWithPermission(relationshipsRequest);

            if (response.AccountProviderLegalEntities.Any())
            {
                Console.WriteLine($"Provider with UKPRN {relationshipsRequest.Ukprn} has AccountProviderLegalEntities with {relationshipsRequest.Operation} permission");
            }
        }
Esempio n. 4
0
        private async Task CheckProviderHasPermission(long providerId, long accountLegalEntityId)
        {
            var permissionsRequest = new GetAccountProviderLegalEntitiesWithPermissionRequest
            {
                Ukprn     = providerId,
                Operation = Operation.CreateCohort
            };

            var permissions = await
                              _providerRelationshipsApiClient.GetAccountProviderLegalEntitiesWithPermission(permissionsRequest);

            if (permissions.AccountProviderLegalEntities.All(x => x.AccountLegalEntityId != accountLegalEntityId))
            {
                throw new DomainException(nameof(accountLegalEntityId), $"Provider {providerId} does not have {nameof(Operation.CreateCohort)} permission for AccountLegalEntity {accountLegalEntityId} in order to create a Change of Party request");
            }
        }
        public Task <GetAccountProviderLegalEntitiesWithPermissionResponse> GetAccountProviderLegalEntitiesWithPermission(
            GetAccountProviderLegalEntitiesWithPermissionRequest withPermissionRequest,
            CancellationToken cancellationToken = new CancellationToken())
        {
            const int accountId             = 1;
            const int accountLegalEntityId1 = 123;
            const int accountLegalEntityId2 = 456;
            const int accountLegalEntityId3 = 789;

            return(Task.FromResult(new GetAccountProviderLegalEntitiesWithPermissionResponse
            {
                AccountProviderLegalEntities = new []
                {
                    new AccountProviderLegalEntityDto
                    {
                        AccountId = accountId,
                        AccountPublicHashedId = _encodingService.Encode(accountId, EncodingType.PublicAccountId),
                        AccountName = "Account 1",
                        AccountLegalEntityId = accountLegalEntityId1,
                        AccountLegalEntityPublicHashedId = _encodingService.Encode(accountLegalEntityId1, EncodingType.PublicAccountLegalEntityId),
                        AccountLegalEntityName = "Legal Entity 1",
                        AccountProviderId = withPermissionRequest.Ukprn
                    },
                    new AccountProviderLegalEntityDto
                    {
                        AccountId = accountId,
                        AccountPublicHashedId = _encodingService.Encode(accountId, EncodingType.PublicAccountId),
                        AccountName = "Account 1",
                        AccountLegalEntityId = accountLegalEntityId2,
                        AccountLegalEntityPublicHashedId = _encodingService.Encode(accountLegalEntityId2, EncodingType.PublicAccountLegalEntityId),
                        AccountLegalEntityName = "Legal Entity 2",
                        AccountProviderId = withPermissionRequest.Ukprn
                    },
                    new AccountProviderLegalEntityDto
                    {
                        AccountId = accountId,
                        AccountPublicHashedId = _encodingService.Encode(accountId, EncodingType.PublicAccountId),
                        AccountName = "Account 1",
                        AccountLegalEntityId = accountLegalEntityId3,
                        AccountLegalEntityPublicHashedId = _encodingService.Encode(accountLegalEntityId3, EncodingType.PublicAccountLegalEntityId),
                        AccountLegalEntityName = "Legal Entity 3",
                        AccountProviderId = withPermissionRequest.Ukprn
                    }
                }
            }));
        }
        public Task <bool> HasRelationshipWithPermission()
        {
            GetAccountProviderLegalEntitiesWithPermissionRequest = new GetAccountProviderLegalEntitiesWithPermissionRequest
            {
                Ukprn     = 11111111,
                Operation = Operation.CreateCohort
            };

            HasRelationshipWithPermissionRequest = new HasRelationshipWithPermissionRequest
            {
                Ukprn     = 11111111,
                Operation = Operation.CreateCohort
            };

            Mediator.Setup(m => m.Send(It.Is <HasRelationshipWithPermissionQuery>(q => q.Ukprn == HasRelationshipWithPermissionRequest.Ukprn && q.Operation == HasRelationshipWithPermissionRequest.Operation), CancellationToken))
            .ReturnsAsync(() => Relationships.Any());

            return(ProviderRelationshipsApiClient.HasRelationshipWithPermission(HasRelationshipWithPermissionRequest, CancellationToken));
        }
 public async Task <GetAccountProviderLegalEntitiesWithPermissionResponse> GetAccountProviderLegalEntitiesWithPermission(GetAccountProviderLegalEntitiesWithPermissionRequest withPermissionRequest, CancellationToken cancellationToken = default)
 {
     return(await _restHttpClient.Get <GetAccountProviderLegalEntitiesWithPermissionResponse>("accountproviderlegalentities", withPermissionRequest, cancellationToken));
 }