Example #1
0
        public async Task GetGatewayPageCommonDetails_When_GatewayReviewStatus_New_Starts_GatewayReview()
        {
            _application.GatewayReviewStatus = GatewayReviewStatus.New;

            var request = new Types.Requests.GatewayCommonDetailsRequest
            {
                UserId   = _userId,
                UserName = _userName,
                PageId   = _pageId
            };
            await _controller.GetGatewayCommonDetails(_applicationId, request);

            _mediator.Verify(x => x.Send(It.IsAny <GetApplicationRequest>(), It.IsAny <CancellationToken>()), Times.AtLeastOnce);
            _mediator.Verify(x => x.Send(It.IsAny <StartGatewayReviewRequest>(), It.IsAny <CancellationToken>()), Times.Once);
        }
Example #2
0
        public async Task GetGatewayPageCommonDetails_When_GatewayReviewStatus_New_Saves_ExternalApi_Checks()
        {
            _application.GatewayReviewStatus = GatewayReviewStatus.New;

            var request = new Types.Requests.GatewayCommonDetailsRequest
            {
                UserId   = _userId,
                UserName = _userName,
                PageId   = _pageId
            };
            await _controller.GetGatewayCommonDetails(_applicationId, request);

            _mediator.Verify(x => x.Send(It.IsAny <GetApplicationRequest>(), It.IsAny <CancellationToken>()), Times.AtLeastOnce);
            _gatewayApiChecksService.Verify(x => x.GetExternalApiCheckDetails(_applicationId), Times.Once);
            _mediator.Verify(x => x.Send(It.IsAny <UpdateExternalApiCheckDetailsRequest>(), It.IsAny <CancellationToken>()), Times.Once);
        }
Example #3
0
        public async Task <ActionResult <GatewayCommonDetails> > GetGatewayCommonDetails(Guid applicationId, [FromBody] Types.Requests.GatewayCommonDetailsRequest request)
        {
            var application = await _mediator.Send(new GetApplicationRequest(applicationId));

            if (application?.ApplyData is null)
            {
                return(NotFound());
            }

            if (application.GatewayReviewStatus == GatewayReviewStatus.New)
            {
                _logger.LogInformation($"Starting Gateway Review for application {application.ApplicationId}");
                await _mediator.Send(new StartGatewayReviewRequest(application.ApplicationId, request.UserId, request.UserName));

                _logger.LogInformation($"Getting external API checks data for application {application.ApplicationId}");
                var gatewayExternalApiCheckDetails = await _gatewayApiChecksService.GetExternalApiCheckDetails(application.ApplicationId);

                await _mediator.Send(new UpdateExternalApiCheckDetailsRequest(application.ApplicationId, gatewayExternalApiCheckDetails, request.UserId, request.UserName));

                // must refresh to get latest information
                application = await _mediator.Send(new GetApplicationRequest(application.ApplicationId));
            }

            var gatewayPage = await _mediator.Send(new GetGatewayPageAnswerRequest(application.ApplicationId, request.PageId));

            if (gatewayPage is null)
            {
                _logger.LogWarning($"Could not find page details for application {application.ApplicationId} | pageId {request.PageId}");
                gatewayPage = new GatewayPageAnswer
                {
                    ApplicationId = application.ApplicationId,
                    PageId        = request.PageId
                };
            }

            return(new GatewayCommonDetails
            {
                ApplicationId = gatewayPage.ApplicationId,
                Ukprn = application.ApplyData.ApplyDetails.UKPRN,
                ApplicationSubmittedOn = application.ApplyData.ApplyDetails.ApplicationSubmittedOn,
                GatewayOutcomeMadeOn = application.ApplyData.GatewayReviewDetails?.OutcomeDateTime,
                GatewayOutcomeMadeBy = application.GatewayUserName,
                SourcesCheckedOn = application.ApplyData.GatewayReviewDetails?.SourcesCheckedOn,
                LegalName = application.ApplyData.ApplyDetails.OrganisationName,
                ProviderRouteName = application.ApplyData.ApplyDetails.ProviderRouteName,
                ApplicationStatus = application.ApplicationStatus,
                GatewayReviewStatus = application.GatewayReviewStatus,
                PageId = gatewayPage.PageId,
                Status = gatewayPage.Status,
                Comments = gatewayPage.Comments,
                OutcomeMadeOn = gatewayPage.UpdatedAt,
                OutcomeMadeBy = gatewayPage.UpdatedBy,
                GatewaySubcontractorDeclarationClarificationUpload = application.ApplyData.GatewayReviewDetails?.GatewaySubcontractorDeclarationClarificationUpload,
                ClarificationComments = gatewayPage.ClarificationComments,
                ClarificationBy = gatewayPage.ClarificationBy,
                ClarificationDate = gatewayPage.ClarificationDate,
                ClarificationAnswer = gatewayPage.ClarificationAnswer
            });
        }