コード例 #1
0
        public void GivenThereAreEligibleApprenticeshipsForTheGrant()
        {
            _apprenticeshipData = _data.Apprentices;
            _legalEntity        = _data.LegalEntities.First();

            _testContext.EmployerIncentivesApi.MockServer
            .Given(
                Request
                .Create()
                .WithPath($"/apprenticeships")
                .WithParam("accountid", _data.AccountId.ToString())
                .WithParam("accountlegalentityid", _data.AccountLegalEntityId.ToString())
                .UsingGet()
                )
            .RespondWith(
                Response.Create()
                .WithBody(JsonConvert.SerializeObject(_apprenticeshipData, TestHelper.DefaultSerialiserSettings))
                .WithStatusCode(HttpStatusCode.OK));

            _testContext.EmployerIncentivesApi.MockServer
            .Given(
                Request
                .Create()
                .WithPath($"/accounts/{_data.AccountId}/legalentities/{_legalEntity.AccountLegalEntityId}")
                .UsingGet()
                )
            .RespondWith(
                Response.Create()
                .WithBody(JsonConvert.SerializeObject(_legalEntity))
                .WithStatusCode(HttpStatusCode.OK));
        }
コード例 #2
0
 public EmploymentStartDatesSteps(TestContext testContext) : base(testContext)
 {
     _testContext    = testContext;
     _hashingService = _testContext.HashingService;
     _data           = new TestData.Account.WithInitialApplicationForASingleEntity();
     _legalEntity    = _data.LegalEntities.First();
     _testContext.AddOrReplaceClaim(EmployerClaimTypes.Account, _data.HashedAccountId);
 }
 public static LegalEntity Map(this LegalEntityDto legalEntityDto)
 {
     return(new LegalEntity(
                new Account(legalEntityDto.AccountId, legalEntityDto.AccountLegalEntityId),
                legalEntityDto.LegalEntityId,
                legalEntityDto.LegalEntityName,
                legalEntityDto.VrfVendorId,
                legalEntityDto.VrfCaseStatus,
                legalEntityDto.HashedLegalEntityId));
 }
コード例 #4
0
        public async Task WhenAClientRequestsTheLegalEntity()
        {
            var url = $"/accounts/{_testAccountTable.Id}/LegalEntities/{_testAccountTable.AccountLegalEntityId}";

            var(status, data) =
                await EmployerIncentiveApi.Client.GetValueAsync <LegalEntityDto>(url);

            status.Should().Be(HttpStatusCode.OK);

            _getLegalEntityResponse = data;
        }
コード例 #5
0
 public IActionResult EditBusinessEntity([FromBody] LegalEntityDto legalEntityDto, int Id)
 {
     try
     {
         return(Ok(_userService.EditBusinessEntity(Id, legalEntityDto, Convert.ToInt32(_httpContextAccessor.HttpContext.User.Identity.Name))));
     }
     catch (AppException ex)
     {
         // return error message if there was an exception
         return(Ok(new { status = false, message = ex.Message }));
     }
 }
        public void GivenAnEmployerApplyingForAGrantHasNoExistingAppliedForApprenticeshipIncentives()
        {
            _apprenticeshipData = new List <ApprenticeshipIncentiveModel>();
            _legalEntity        = _data.LegalEntities.First();

            var accountId = _testData.GetOrCreate("AccountId", onCreate: () => _data.AccountId);

            _testData.Add("HashedAccountId", _hashingService.HashValue(accountId));
            _testContext.AddOrReplaceClaim(EmployerClaimTypes.Account, _hashingService.HashValue(accountId));
            var accountLegalEntityId = _testData.GetOrCreate("AccountLegalEntityId", onCreate: () => _legalEntity.AccountLegalEntityId);

            _testData.Add("HashedAccountLegalEntityId", _hashingService.HashValue(accountLegalEntityId));

            _testContext.EmployerIncentivesApi.MockServer
            .Given(
                Request
                .Create()
                .WithPath($"/accounts/{accountId}/legalentities/{_legalEntity.AccountLegalEntityId}/apprenticeshipIncentives")
                .UsingGet()
                )
            .RespondWith(
                Response.Create()
                .WithBody(JsonConvert.SerializeObject(_apprenticeshipData, TestHelper.DefaultSerialiserSettings))
                .WithStatusCode(HttpStatusCode.OK));

            _testContext.EmployerIncentivesApi.MockServer
            .Given(
                Request
                .Create()
                .WithPath($"/accounts/{_data.AccountId}/legalentities/{_legalEntity.AccountLegalEntityId}")
                .UsingGet()
                )
            .RespondWith(
                Response.Create()
                .WithBody(JsonConvert.SerializeObject(_legalEntity))
                .WithStatusCode(HttpStatusCode.OK));

            _testContext.EmployerIncentivesApi.MockServer
            .Given(
                Request
                .Create()
                .WithPath($"/accounts/{_data.AccountId}/legalentity/{_legalEntity.AccountLegalEntityId}/applications")
                .UsingGet()
                )
            .RespondWith(
                Response.Create()
                .WithStatusCode(HttpStatusCode.OK)
                .WithHeader("Content-Type", "application/json")
                .WithBody(JsonConvert.SerializeObject(_data.GetApplicationsResponse, TestHelper.DefaultSerialiserSettings)));
        }
コード例 #7
0
 public static LegalEntityModel ToLegalEntityModel(this LegalEntityDto dto, IHashingService hashingService)
 {
     return(new LegalEntityModel
     {
         AccountId = hashingService.HashValue(dto.AccountId),
         AccountLegalEntityId = hashingService.HashValue(dto.AccountLegalEntityId),
         Name = dto.LegalEntityName,
         VrfCaseStatus = dto.VrfCaseStatus,
         IsAgreementSigned = dto.IsAgreementSigned,
         VrfVendorId = dto.VrfVendorId,
         HashedLegalEntityId = dto.HashedLegalEntityId,
         BankDetailsRequired = dto.BankDetailsRequired
     });
 }
 public static LegalEntityModel ToLegalEntityModel(this LegalEntityDto dto, IHashingService hashingService)
 {
     return(new LegalEntityModel
     {
         AccountId = hashingService.HashValue(dto.AccountId),
         AccountLegalEntityId = hashingService.HashValue(dto.AccountLegalEntityId),
         Name = dto.LegalEntityName,
         HasSignedIncentiveTerms = dto.HasSignedIncentivesTerms,
         VrfCaseStatus = dto.VrfCaseStatus,
         SignedAgreementVersion = dto.SignedAgreementVersion,
         VrfVendorId = dto.VrfVendorId,
         HashedLegalEntityId = dto.HashedLegalEntityId
     });
 }
コード例 #9
0
 public IActionResult AddBusinessEntity([FromBody] LegalEntityDto legalEntityDto)
 {
     try
     {
         var businessEntity = _mapper.Map <LegalEntity>(legalEntityDto);
         businessEntity.UserId = Convert.ToInt32(_httpContextAccessor.HttpContext.User.Identity.Name);
         _userService.AddBusinessEntity(businessEntity);
         return(Ok(new { status = true }));
     }
     catch (AppException ex)
     {
         // return error message if there was an exception
         return(Ok(new { code = false, message = ex.Message }));
     }
 }
コード例 #10
0
        public LegalEntity EditBusinessEntity(int Id, LegalEntityDto legalEntityDto, int userId)
        {
            var entity = _context.LegalEntity.SingleOrDefault(x => x.Id == Id);

            if (entity == null)
            {
                throw new AppException("Business Entity Not Found");
            }
            if (entity.UserId != userId)
            {
                throw new AppException("User is not an owner of this Business Entity");
            }
            _mapper.Map <LegalEntityDto, LegalEntity>(legalEntityDto, entity);
            _context.LegalEntity.Update(entity);
            entity.LogoImage = _context.Images.SingleOrDefault(x => x.ImageId == entity.Logo);
            return(entity);
        }
        public async Task Then_a_Created_response_is_returned()
        {
            // Arrange
            var request   = _fixture.Create <AddLegalEntityRequest>();
            var accountId = _fixture.Create <long>();

            var expected = new LegalEntityDto {
                AccountId            = accountId,
                AccountLegalEntityId = request.AccountLegalEntityId,
                LegalEntityId        = request.LegalEntityId,
                LegalEntityName      = request.OrganisationName
            };

            // Act
            var actual = await _sut.UpsertLegalEntity(accountId, request) as CreatedResult;

            // Assert
            actual.Should().NotBeNull();
            actual.Value.Should().BeEquivalentTo(expected);
        }
        public void GivenAnEmployerApplyingForAGrantHasApprenticesMatchingTheEligibilityRequirement()
        {
            var data = new TestData.Account.WithInitialApplicationForASingleEntity();

            _apprenticeshipData = data.Apprentices;
            _legalEntity        = data.LegalEntities.First();

            var accountId = _testData.GetOrCreate("AccountId", onCreate: () => data.AccountId);

            _testData.Add("HashedAccountId", _hashingService.HashValue(accountId));
            _testContext.AddOrReplaceClaim(EmployerClaimTypes.Account, _hashingService.HashValue(accountId));
            var accountLegalEntityId = _testData.GetOrCreate("AccountLegalEntityId", onCreate: () => data.AccountLegalEntityId);

            _testData.Add("HashedAccountLegalEntityId", _hashingService.HashValue(accountLegalEntityId));

            _testContext.EmployerIncentivesApi.MockServer
            .Given(
                Request
                .Create()
                .WithPath($"/apprenticeships")
                .WithParam("accountid", accountId.ToString())
                .WithParam("accountlegalentityid", accountLegalEntityId.ToString())
                .UsingGet()
                )
            .RespondWith(
                Response.Create()
                .WithBody(JsonConvert.SerializeObject(_apprenticeshipData, TestHelper.DefaultSerialiserSettings))
                .WithStatusCode(HttpStatusCode.OK));

            _testContext.EmployerIncentivesApi.MockServer
            .Given(
                Request
                .Create()
                .WithPath($"/accounts/{accountId}/applications")
                .UsingPost()
                )
            .RespondWith(
                Response.Create()
                .WithStatusCode(HttpStatusCode.Created));

            _testContext.EmployerIncentivesApi.MockServer
            .Given(
                Request
                .Create()
                .WithPath(x => x.Contains($"/accounts/{data.AccountId}/applications/") && !x.Contains("accountlegalentity"))
                .UsingGet()
                )
            .RespondWith(
                Response.Create()
                .WithStatusCode(HttpStatusCode.OK)
                .WithHeader("Content-Type", "application/json")
                .WithBody(JsonConvert.SerializeObject(data.ApplicationResponse, TestHelper.DefaultSerialiserSettings)));

            _testContext.EmployerIncentivesApi.MockServer
            .Given(
                Request
                .Create()
                .WithPath($"/accounts/{accountId}/applications")
                .UsingPost()
                )
            .RespondWith(
                Response.Create()
                .WithStatusCode(HttpStatusCode.Created)
                .WithHeader("Content-Type", "application/json")
                .WithBody(string.Empty));

            _testContext.EmployerIncentivesApi.MockServer
            .Given(
                Request
                .Create()
                .WithPath(x =>
                          x.Contains($"accounts/{data.AccountId}/applications") &&
                          x.Contains("accountlegalentity")) // applicationid is generated in application service so will vary per request
                .UsingGet()
                )
            .RespondWith(
                Response.Create()
                .WithStatusCode(HttpStatusCode.OK)
                .WithHeader("Content-Type", "application/json")
                .WithBody(data.AccountLegalEntityId.ToString()));

            _testContext.EmployerIncentivesApi.MockServer
            .Given(
                Request
                .Create()
                .WithPath($"/accounts/{data.AccountId}/legalentities/{_legalEntity.AccountLegalEntityId}")
                .UsingGet()
                )
            .RespondWith(
                Response.Create()
                .WithBody(JsonConvert.SerializeObject(_legalEntity))
                .WithStatusCode(HttpStatusCode.OK));
        }