Ejemplo n.º 1
0
        public void Setup()
        {
            CoreSetup();
            _logger       = new Mock <ILogger <RoatpGatewayPeopleInControlController> >();
            _orchestrator = new Mock <IPeopleInControlOrchestrator>();
            ViewModel     = new PeopleInControlPageViewModel {
                ApplicationId = _applicationId
            };

            Request = new GetPeopleInControlRequest(_applicationId, UserId, Username);
            _orchestrator.Setup(x =>
                                x.GetPeopleInControlViewModel(It.IsAny <GetPeopleInControlRequest>()))
            .ReturnsAsync(ViewModel)
            .Verifiable("view model not returned");

            _controller = new RoatpGatewayPeopleInControlController(ApplyApiClient.Object, _logger.Object, GatewayValidator.Object, _orchestrator.Object);

            _controller.ControllerContext = MockedControllerContext.Setup();
            UserId   = _controller.ControllerContext.HttpContext.User.UserId();
            Username = _controller.ControllerContext.HttpContext.User.UserDisplayName();
        }
        public async Task <PeopleInControlPageViewModel> GetPeopleInControlViewModel(GetPeopleInControlRequest request)
        {
            _logger.LogInformation($"Retrieving people in control details for application {request.ApplicationId}");

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

            _logger.LogInformation($"Retrieving people in control - type of organisation for application {request.ApplicationId}");
            model.TypeOfOrganisation = await _organisationSummaryApiClient.GetTypeOfOrganisation(request.ApplicationId);

            _logger.LogInformation($"Retrieving company number in control for application {request.ApplicationId}");
            model.CompanyNumber = await _organisationSummaryApiClient.GetCompanyNumber(request.ApplicationId);

            _logger.LogInformation($"Retrieving company number in control for application {request.ApplicationId}");
            model.CharityNumber = await _organisationSummaryApiClient.GetCharityNumber(request.ApplicationId);


            _logger.LogInformation($"Retrieving people in control - [{RoatpGatewayConstants.PeopleInControl.Heading.CompanyDirectors}] for application {request.ApplicationId}");
            model.CompanyDirectorsData = new PeopleInControlData
            {
                Caption = RoatpGatewayConstants.PeopleInControl.Heading.CompanyDirectors,
                ExternalSourceHeading    = RoatpGatewayConstants.PeopleInControl.Caption.CompaniesHouse,
                FromExternalSource       = await _organisationSummaryApiClient.GetDirectorsFromCompaniesHouse(request.ApplicationId),
                FromSubmittedApplication = await _organisationSummaryApiClient.GetDirectorsFromSubmitted(request.ApplicationId)
            };

            _logger.LogInformation($"Retrieving people in control - [{RoatpGatewayConstants.PeopleInControl.Heading.PeopleWithSignificantControl}] for application {request.ApplicationId}");
            model.PscData = new PeopleInControlData
            {
                Caption = RoatpGatewayConstants.PeopleInControl.Heading.PeopleWithSignificantControl,
                ExternalSourceHeading    = RoatpGatewayConstants.PeopleInControl.Caption.CompaniesHouse,
                FromExternalSource       = await _organisationSummaryApiClient.GetPscsFromCompaniesHouse(request.ApplicationId),
                FromSubmittedApplication = await _organisationSummaryApiClient.GetPscsFromSubmitted(request.ApplicationId)
            };

            _logger.LogInformation($"Retrieving people in control - [{RoatpGatewayConstants.PeopleInControl.Heading.Trustees}] for application {request.ApplicationId}");
            model.TrusteeData = new PeopleInControlData
            {
                Caption = RoatpGatewayConstants.PeopleInControl.Heading.Trustees,
                ExternalSourceHeading    = RoatpGatewayConstants.PeopleInControl.Caption.CharityCommission,
                FromExternalSource       = await _organisationSummaryApiClient.GetTrusteesFromCharityCommission(request.ApplicationId),
                FromSubmittedApplication = await _organisationSummaryApiClient.GetTrusteesFromSubmitted(request.ApplicationId)
            };

            _logger.LogInformation($"Retrieving people in control - [{RoatpGatewayConstants.PeopleInControl.Heading.WhosInControl}] for application {request.ApplicationId}");
            model.WhosInControlData = new PeopleInControlData
            {
                Caption = RoatpGatewayConstants.PeopleInControl.Heading.WhosInControl,
                ExternalSourceHeading    = null,
                FromExternalSource       = null,
                FromSubmittedApplication =
                    await _organisationSummaryApiClient.GetWhosInControlFromSubmitted(request.ApplicationId)
            };

            return(model);
        }