public async Task <IActionResult> Grade(FinancialApplicationViewModel vm)
        {
            var application = await _applyApiClient.GetApplication(vm.Id);

            if (application is null)
            {
                return(RedirectToAction(nameof(OpenApplications)));
            }

            if (ModelState.IsValid)
            {
                var financialSequence = await _qnaApiClient.GetSequenceBySequenceNo(application.ApplicationId, ApplyConst.FINANCIAL_SEQUENCE_NO);

                var financialSection = await _qnaApiClient.GetSectionBySectionNo(application.ApplicationId, ApplyConst.FINANCIAL_SEQUENCE_NO, ApplyConst.FINANCIAL_DETAILS_SECTION_NO);

                var grade = new FinancialGrade
                {
                    ApplicationReference      = application.ApplyData.Apply.ReferenceNumber,
                    GradedBy                  = _contextAccessor.HttpContext.User.UserDisplayName(),
                    GradedDateTime            = DateTime.UtcNow,
                    SelectedGrade             = vm.Grade.SelectedGrade,
                    FinancialDueDate          = GetFinancialDueDate(vm),
                    FinancialEvidences        = GetFinancialEvidence(financialSequence, financialSection),
                    InadequateMoreInformation = vm.Grade.InadequateMoreInformation
                };

                await _applyApiClient.ReturnFinancialReview(vm.Id, grade);

                return(RedirectToAction(nameof(Evaluated), new { vm.Id }));
            }
            else
            {
                var newvm = await CreateFinancialApplicationViewModel(application, vm.Grade);

                return(View("~/Views/Apply/Financial/Application.cshtml", newvm));
            }
        }
        private async Task <FinancialApplicationViewModel> CreateFinancialApplicationViewModel(ApplicationResponse applicationFromAssessor, FinancialGrade grade)
        {
            if (applicationFromAssessor is null)
            {
                return(new FinancialApplicationViewModel());
            }
            else if (grade is null)
            {
                grade = applicationFromAssessor.FinancialGrade;
            }

            var financialSection = await _qnaApiClient.GetSectionBySectionNo(applicationFromAssessor.ApplicationId, ApplyConst.FINANCIAL_SEQUENCE_NO, ApplyConst.FINANCIAL_DETAILS_SECTION_NO);

            var orgId        = applicationFromAssessor.OrganisationId;
            var organisation = await _apiClient.GetOrganisation(orgId);

            var application = new AssessorService.ApplyTypes.Application
            {
                ApplicationData = new ApplicationData
                {
                    ReferenceNumber = applicationFromAssessor.ApplyData.Apply.ReferenceNumber
                },
                ApplyingOrganisation   = organisation,
                ApplyingOrganisationId = orgId,
                ApplicationStatus      = applicationFromAssessor.ApplicationStatus
            };

            return(new FinancialApplicationViewModel(applicationFromAssessor.Id, applicationFromAssessor.ApplicationId, financialSection, grade, application));
        }