private static DateTime?GetFinancialDueDate(FinancialApplicationViewModel vm)
        {
            if (vm is null)
            {
                return(null);
            }

            switch (vm?.Grade?.SelectedGrade)
            {
            case FinancialApplicationSelectedGrade.Outstanding:
                return(vm.OutstandingFinancialDueDate?.ToDateTime());

            case FinancialApplicationSelectedGrade.Good:
                return(vm.GoodFinancialDueDate?.ToDateTime());

            case FinancialApplicationSelectedGrade.Satisfactory:
                return(vm.SatisfactoryFinancialDueDate?.ToDateTime());

            case FinancialApplicationSelectedGrade.Monitoring:
                return(vm.MonitoringFinancialDueDate?.ToDateTime());

            default:
                return(null);
            }
        }
        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));
            }
        }