Beispiel #1
0
        public async Task Then_a_warning_message_is_not_shown_if_the_signed_legal_agreement_version_is_the_latest_version()
        {
            // Arrange
            var legalEntity = new LegalEntityModel
            {
                AccountId               = _accountId,
                AccountLegalEntityId    = _accountLegalEntityId,
                HasSignedIncentiveTerms = true,
                SignedAgreementVersion  = 5,
                Name = "Organisation Name"
            };
            var legalEntities = new List <LegalEntityModel> {
                legalEntity
            };

            _legalEntitiesService.Setup(x => x.Get(_accountId)).ReturnsAsync(legalEntities);

            // Act
            var result = await _sut.Start(_accountId, _accountLegalEntityId);

            // Assert
            var viewResult = result as ViewResult;

            viewResult.Should().NotBeNull();
            var model = viewResult.Model as HomeViewModel;

            model.Should().NotBeNull();
            model.NewAgreementRequired.Should().BeFalse();
        }
Beispiel #2
0
        public async Task Then_a_warning_message_advising_about_the_signed_legal_agreement_version_is_shown()
        {
            // Arrange
            var legalEntity = new LegalEntityModel
            {
                AccountId               = _accountId,
                AccountLegalEntityId    = _accountLegalEntityId,
                HasSignedIncentiveTerms = true,
                SignedAgreementVersion  = 4,
                Name = "Organisation Name"
            };
            var legalEntities = new List <LegalEntityModel> {
                legalEntity
            };

            _legalEntitiesService.Setup(x => x.Get(_accountId)).ReturnsAsync(legalEntities);

            // Act
            var result = await _sut.Start(_accountId, _accountLegalEntityId);

            // Assert
            var viewResult = result as ViewResult;

            viewResult.Should().NotBeNull();
            var model = viewResult.Model as HomeViewModel;

            model.Should().NotBeNull();
            model.NewAgreementRequired.Should().BeTrue();
            model.OrganisationName.Should().Be(legalEntity.Name);
            model.AccountsAgreementsUrl.Should().Be($"{_externalLinks.ManageApprenticeshipSiteUrl}/accounts/{_accountId}/agreements");
        }
    protected void btnSubmit_OnClick(object sender, EventArgs e)
    {
        var model = new LegalEntityModel
        {
            Name = name.Text,
            Iin  = iin.Text
        };

        _legalEntityService.Create(model);
        legalEntityGrid.DataBind();
    }
        public void Create(LegalEntityModel model)
        {
            var legal = new LegalEntity
            {
                Iin  = model.Iin,
                Name = model.Name,
            };

            _dbContext.LegalEntities.Add(legal);
            _dbContext.SaveChanges();
        }
Beispiel #5
0
 public static LegalEntityDto Map(this LegalEntityModel model, long accountId)
 {
     return(new LegalEntityDto
     {
         AccountId = accountId,
         AccountLegalEntityId = model.AccountLegalEntityId,
         HasSignedIncentivesTerms = model.HasSignedAgreementTerms,
         LegalEntityId = model.Id,
         LegalEntityName = model.Name,
         VrfVendorId = model.VrfVendorId,
         VrfCaseStatus = model.VrfCaseStatus,
         HashedLegalEntityId = model.HashedLegalEntityId
     });
 }
Beispiel #6
0
        public async Task UpdateVrfCaseStatus(LegalEntityModel legalEntity)
        {
            var accountId            = _hashingService.DecodeValue(legalEntity.AccountId);
            var accountLegalEntityId = _hashingService.DecodeValue(legalEntity.AccountLegalEntityId);

            var queryParams = new Dictionary <string, string>
            {
                { "vrfCaseStatus", legalEntity.VrfCaseStatus }
            };
            var url = QueryHelpers.AddQueryString(OuterApiRoutes.LegalEntities.UpdateVrfCaseStatus(accountId, accountLegalEntityId), queryParams);

            using var response = await _client.PutAsync(url, new StringContent (string.Empty));

            response.EnsureSuccessStatusCode();
        }
        public async Task Then_the_agreement_status_of_the_legal_entity_is_updated()
        {
            //Arrange
            var command          = new SignLegalEntityAgreementCommand(_fixture.Create <long>(), _fixture.Create <long>(), ExpectedMinimumVersion);
            var legalEntityModel = new LegalEntityModel {
                Id = command.AccountLegalEntityId, AccountLegalEntityId = command.AccountLegalEntityId
            };
            var expectedAccount = Account.Create(new AccountModel {
                Id = 1, LegalEntityModels = new Collection <LegalEntityModel> {
                    legalEntityModel
                }
            });

            _mockDomainRepository
            .Setup(m => m.Find(command.AccountId))
            .ReturnsAsync(expectedAccount);

            //Act
            await _sut.Handle(command);

            //Assert
            _mockDomainRepository.Verify(m => m.Save(expectedAccount), Times.Once);
        }
 public void Edit(int id, LegalEntityModel model)
 {
     throw new NotImplementedException();
 }
Beispiel #9
0
 public static LegalEntity Map(this LegalEntityModel model)
 {
     return(LegalEntity.Create(model));
 }
        public async Task GivenAmendApplication_WhenAgreedToEnterBankDetails_ThenBuildsEncryptedAchieveServiceUrl()
        {
            // Arrange
            const int    accountId                  = 20001;
            const string hashedAccountId            = "XFS24D";
            const string hashedAccountLegalEntityId = "G6M7RV";
            var          applicationId              = Guid.NewGuid();
            const long   legalEntityId              = 120001;
            const string hashedLegalEntityId        = "ABCD2X";

            var bankDetails = new BankingDetailsDto
            {
                SubmittedByName         = "Bob Martin",
                SubmittedByEmail        = "*****@*****.**",
                ApplicationValue        = 3000,
                LegalEntityId           = legalEntityId,
                VendorCode              = "ABC123",
                NumberOfApprenticeships = 7,
                SignedAgreements        = new List <SignedAgreementDto>
                {
                    new SignedAgreementDto {
                        SignedByEmail = "*****@*****.**", SignedByName = "Jon Skeet", SignedDate = DateTime.Parse("01-09-2020 12:34:59", new CultureInfo("en-GB"))
                    }
                }
            };

            var bankDetailsServiceMock = new Mock <IBankingDetailsService>();

            bankDetailsServiceMock.Setup(x => x.GetBankingDetails(accountId, applicationId, hashedAccountId)).ReturnsAsync(bankDetails);

            var hashingServiceMock = new Mock <IHashingService>();

            hashingServiceMock.Setup(x => x.DecodeValue(hashedAccountId)).Returns(accountId);
            hashingServiceMock.Setup(x => x.HashValue(legalEntityId)).Returns(hashedLegalEntityId);

            var legalEntitiesServiceMock = new Mock <ILegalEntitiesService>();
            var legalEntity = new LegalEntityModel
            {
                AccountId            = hashedAccountId,
                AccountLegalEntityId = hashedAccountLegalEntityId,
                Name        = "Legal Entity",
                VrfVendorId = "ABC123"
            };

            legalEntitiesServiceMock.Setup(x => x.Get(hashedAccountId, hashedAccountLegalEntityId)).ReturnsAsync(legalEntity);

            var          webConfigurationOptionsMock = new Mock <WebConfigurationOptions>();
            const string achieveServiceBaseUrl       = "https://dfeuat.achieveservice.com/service/provide-organisation-information";

            webConfigurationOptionsMock.Setup(x => x.AchieveServiceBaseUrl).Returns(achieveServiceBaseUrl);
            var mockOptions = new Mock <IOptions <WebConfigurationOptions> >();

            mockOptions.Setup(x => x.Value).Returns(webConfigurationOptionsMock.Object);

            const string returnUrl = "employer-incentives.gov.uk/hub-page";

            const string encryptedData             = "qNgwIVvU8twX0GPjF4yHcw==Qqm35mLvFQZ9RCNQ2Ff7zee2sO4CNS0H7hN9PzKM6Cfo7U+ajB52gza8VEt0F9jnKpTxYt93HWq4xZPrdzEDZw==";
            var          dataEncryptionServiceMock = new Mock <IDataEncryptionService>();

            dataEncryptionServiceMock.Setup(x => x.Encrypt(It.IsAny <string>())).Returns(encryptedData);

            var expectedUrl = $"https://dfeuat.achieveservice.com/service/provide-organisation-information?journey=amend&return={returnUrl.ToUrlString()}&data={encryptedData.ToUrlString()}";

            var sut = new VerificationService(bankDetailsServiceMock.Object, dataEncryptionServiceMock.Object, hashingServiceMock.Object, legalEntitiesServiceMock.Object, webConfigurationOptionsMock.Object);

            // Act
            var actual = await sut.BuildAchieveServiceUrl(hashedAccountId, hashedAccountLegalEntityId, applicationId, returnUrl, amendBankDetails : true);

            // Assert
            actual.Should().Be(expectedUrl);
        }