public async Task <IcoNumberViewModel> GetIcoNumberViewModel(GetIcoNumberRequest request)
        {
            _logger.LogInformation($"Retrieving ICO Number check details for application {request.ApplicationId}");

            var model = new IcoNumberViewModel();
            await model.PopulatePageCommonDetails(_applyApiClient, request.ApplicationId, GatewaySequences.OrganisationChecks,
                                                  GatewayPageIds.IcoNumber,
                                                  request.UserId,
                                                  request.UserName,
                                                  RoatpGatewayConstants.Captions.OrganisationChecks,
                                                  RoatpGatewayConstants.Headings.IcoNumber,
                                                  NoSelectionErrorMessages.Errors[GatewayPageIds.IcoNumber]);


            var organisationAddress = await _applyApiClient.GetOrganisationAddress(request.ApplicationId);

            if (organisationAddress != null)
            {
                var AddressArray = new[] { organisationAddress.Address1, organisationAddress.Address2, organisationAddress.Address3, organisationAddress.Address4, organisationAddress.Town, organisationAddress.PostCode };
                model.OrganisationAddress = string.Join(", ", AddressArray.Where(s => !string.IsNullOrEmpty(s)));
            }

            var icoNumber = await _applyApiClient.GetIcoNumber(request.ApplicationId);

            model.IcoNumber = icoNumber.Value;

            return(model);
        }
Beispiel #2
0
        public void check_orchestrator_builds_with_ico_number()
        {
            var applicationId = Guid.NewGuid();

            var commonDetails = new GatewayCommonDetails
            {
                ApplicationSubmittedOn = DateTime.Now.AddDays(-3),
                SourcesCheckedOn       = DateTime.Now,
                LegalName = UKRLPLegalName,
                Ukprn     = ukprn
            };

            _applyApiClient.Setup(x => x.GetPageCommonDetails(It.IsAny <Guid>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())).ReturnsAsync(commonDetails);

            // SubmittedApplicationAddress
            var expectedOrganisationAddress = "1 QnA Street, Second Address, Third Address, Forth Address, Coventry, CV2 1WT";

            var organisationAddressResult = new ContactAddress
            {
                Address1 = "1 QnA Street",
                Address2 = "Second Address",
                Address3 = "Third Address",
                Address4 = "Forth Address",
                Town     = "Coventry",
                PostCode = "CV2 1WT"
            };

            _applyApiClient.Setup(x => x.GetOrganisationAddress(It.IsAny <Guid>())).ReturnsAsync(organisationAddressResult);


            // SubmittedApplicationIcoNumber
            var expectedIcoNumberIcoNumber = "1234QWER";
            var icoNumberResult            = new IcoNumber {
                Value = "1234QWER"
            };


            _applyApiClient.Setup(x => x.GetIcoNumber(It.IsAny <Guid>())).ReturnsAsync(icoNumberResult);



            var request = new GetIcoNumberRequest(applicationId, UserId, UserName);

            var response = _orchestrator.GetIcoNumberViewModel(request);

            var viewModel = response.Result;

            Assert.AreEqual(UKRLPLegalName, viewModel.ApplyLegalName);
            Assert.AreEqual(ukprn, viewModel.Ukprn);
            Assert.AreEqual(expectedOrganisationAddress, viewModel.OrganisationAddress);
            Assert.AreEqual(expectedIcoNumberIcoNumber, viewModel.IcoNumber);
        }