public async Task <ApplicationSummaryViewModel> BuildApplicationSummaryViewModel(Guid applicationId, string emailAddress)
        {
            var application = await _applicationApiClient.GetApplication(applicationId);

            var financialReviewDetails = await _applicationApiClient.GetFinancialReviewDetails(applicationId);

            GetOversightReviewResponse oversightReview = null;
            GetAppealResponse          appeal          = null;

            var applyingJourneyStatuses = new List <string> {
                ApplicationStatus.New, ApplicationStatus.InProgress
            };

            if (!applyingJourneyStatuses.Contains(application.Status))
            {
                oversightReview = await _apiClient.GetOversightReview(applicationId);

                appeal = await _appealsApiClient.GetAppeal(applicationId);
            }

            var applicationData = application.ApplyData.ApplyDetails;

            var model = new ApplicationSummaryViewModel
            {
                ApplicationId                       = application.ApplicationId,
                UKPRN                               = applicationData.UKPRN,
                OrganisationName                    = applicationData.OrganisationName,
                TradingName                         = applicationData.TradingName,
                ApplicationRouteId                  = applicationData.ProviderRoute.ToString(),
                ApplicationReference                = applicationData.ReferenceNumber,
                SubmittedDate                       = applicationData?.ApplicationSubmittedOn,
                GatewayExternalComments             = application.ExternalComments ?? application.ApplyData.GatewayReviewDetails?.ExternalComments,
                EmailAddress                        = emailAddress,
                FinancialReviewStatus               = financialReviewDetails?.Status,
                FinancialGrade                      = financialReviewDetails?.SelectedGrade,
                FinancialExternalComments           = financialReviewDetails?.ExternalComments,
                GatewayReviewStatus                 = application?.GatewayReviewStatus,
                ModerationStatus                    = application?.ModerationStatus,
                SubcontractingLimit                 = application?.ApplyData?.GatewayReviewDetails?.SubcontractingLimit,
                ApplicationStatus                   = application?.ApplicationStatus,
                ApplicationDeterminedDate           = oversightReview?.ApplicationDeterminedDate,
                OversightReviewStatus               = oversightReview?.Status,
                OversightInProgressExternalComments = oversightReview?.InProgressExternalComments,
                AppealRequiredByDate                = oversightReview is null ? null : await _apiClient.GetWorkingDaysAheadDate(oversightReview?.ApplicationDeterminedDate, NumberOfWorkingDaysToAppeal),
                IsAppealSubmitted                   = appeal?.AppealSubmittedDate != null,
                AppealStatus                        = appeal?.Status
            };

            return(model);
        }
示例#2
0
        public async Task <IActionResult> AppealSubmitted(Guid applicationId)
        {
            var appeal = await _appealsApiClient.GetAppeal(applicationId);

            if (appeal?.AppealSubmittedDate is null)
            {
                return(RedirectToAction("ProcessApplicationStatus", "RoatpOverallOutcome", new { applicationId }));
            }

            var model = new AppealSubmittedViewModel
            {
                ApplicationId                = appeal.ApplicationId,
                AppealSubmittedDate          = appeal.AppealSubmittedDate.Value,
                HowFailedOnEvidenceSubmitted = appeal.HowFailedOnEvidenceSubmitted,
                HowFailedOnPolicyOrProcesses = appeal.HowFailedOnPolicyOrProcesses,
                AppealFiles = appeal.AppealFiles
            };

            return(View("~/Views/Appeals/AppealSubmitted.cshtml", model));
        }
示例#3
0
        public async Task HandleAsync(AuthorizationHandlerContext context)
        {
            _logger.LogInformation("AccessApplicationRequirementHandler invoked");

            var pendingRequirements = context.PendingRequirements.ToList();

            if (!pendingRequirements.Exists(x => x is AccessApplicationRequirement || x is ApplicationStatusRequirement || x is AppealNotYetSubmittedRequirement))
            {
                return;
            }

            var   requestedApplicationId = GetRequestedApplicationId();
            Apply application            = null;

            if (Guid.TryParse(requestedApplicationId, out var applicationId))
            {
                _logger.LogInformation($"Requested application {applicationId}");
                var signInId = _httpContextAccessor.HttpContext.User.GetSignInId();
                application = await _apiClient.GetApplicationByUserId(applicationId, signInId);
            }
            else
            {
                _logger.LogInformation("Unable to determine ApplicationId parameter");
            }

            foreach (var requirement in pendingRequirements)
            {
                _logger.LogInformation($"Evaluating requirement: {requirement.GetType().Name}");

                if (requirement is AccessApplicationRequirement)
                {
                    if (application != null && application.ApplicationId == applicationId)
                    {
                        context.Succeed(requirement);
                        _logger.LogInformation($"Requirement {requirement.GetType().Name} met");
                    }
                    else
                    {
                        _logger.LogInformation($"Requirement {requirement.GetType().Name} not met");
                    }
                }

                if (requirement is ApplicationStatusRequirement statusRequirement)
                {
                    if (application != null && statusRequirement.Statuses.Contains(application.ApplicationStatus))
                    {
                        context.Succeed(requirement);
                        _logger.LogInformation($"Requirement {requirement.GetType().Name} met");
                    }
                    else
                    {
                        var requiredStatus = string.Join(",", statusRequirement.Statuses);
                        var actualStatus   = application == null ? "null" : application?.ApplicationStatus;
                        _logger.LogInformation($"Requirement {requirement.GetType().Name} not met - application status required: one of [{requiredStatus}], actual {actualStatus}");
                    }
                }

                if (requirement is AppealNotYetSubmittedRequirement)
                {
                    if (application != null)
                    {
                        var appeal = await _appealsApiClient.GetAppeal(application.ApplicationId);

                        if (appeal?.AppealSubmittedDate is null)
                        {
                            context.Succeed(requirement);
                            _logger.LogInformation($"Requirement {requirement.GetType().Name} met");
                        }
                        else
                        {
                            _logger.LogInformation($"Requirement {requirement.GetType().Name} not met - appeal has been submitted");
                        }
                    }
                    else
                    {
                        _logger.LogInformation($"Requirement {requirement.GetType().Name} not met - application not found");
                    }
                }
            }
        }