private static string GetFinancialReviewExternalComments(RoatpFinancialApplicationViewModel vm) { switch (vm?.FinancialReviewDetails?.SelectedGrade) { case FinancialApplicationSelectedGrade.Inadequate: return(vm.InadequateExternalComments); case null: default: return(null); } }
public void Validator_rejects_missing_SelectedGrade() { var _viewModel = new RoatpFinancialApplicationViewModel { FinancialReviewDetails = new FinancialReviewDetails { SelectedGrade = null } }; var validationResponse = _validator.Validate(_viewModel); var error = validationResponse.Errors.FirstOrDefault(x => x.PropertyName == "FinancialReviewDetails.SelectedGrade"); error.Should().NotBeNull(); }
public void Validator_rejects_ClarificationComments_above_maxwordcount_when_graded_Clarification() { var _viewModel = new RoatpFinancialApplicationViewModel { ClarificationComments = string.Join(" ", Enumerable.Repeat("a", _maxWordCount + 1)), FinancialReviewDetails = new FinancialReviewDetails { SelectedGrade = FinancialApplicationSelectedGrade.Clarification, } }; var validationResponse = _validator.Validate(_viewModel); var error = validationResponse.Errors.FirstOrDefault(x => x.PropertyName == "ClarificationComments"); error.Should().NotBeNull(); }
public void Validator_rejects_missing_ClarificationComments_when_graded_Clarification() { var _viewModel = new RoatpFinancialApplicationViewModel { ClarificationComments = null, FinancialReviewDetails = new FinancialReviewDetails { SelectedGrade = FinancialApplicationSelectedGrade.Clarification, } }; var validationResponse = _validator.Validate(_viewModel); var error = validationResponse.Errors.FirstOrDefault(x => x.PropertyName == "ClarificationComments"); error.Should().NotBeNull(); }
public void Validator_rejects_missing_InadequateComments_when_graded_Inadequate() { var _viewModel = new RoatpFinancialApplicationViewModel { InadequateComments = null, InadequateExternalComments = "external comments", FinancialReviewDetails = new FinancialReviewDetails { SelectedGrade = FinancialApplicationSelectedGrade.Inadequate, } }; var validationResponse = _validator.Validate(_viewModel); var error = validationResponse.Errors.FirstOrDefault(x => x.PropertyName == "InadequateComments"); error.Should().NotBeNull(); }
public void Validator_rejects_missing_FinancialDueDate_when_graded_Satisfactory() { var _viewModel = new RoatpFinancialApplicationViewModel { SatisfactoryFinancialDueDate = new FinancialDueDate { }, FinancialReviewDetails = new FinancialReviewDetails { SelectedGrade = FinancialApplicationSelectedGrade.Satisfactory, } }; var validationResponse = _validator.Validate(_viewModel); var error = validationResponse.Errors.FirstOrDefault(x => x.PropertyName == "SatisfactoryFinancialDueDate"); error.Should().NotBeNull(); }
public async Task <IActionResult> GradeApplication(Guid applicationId, [FromForm] RoatpFinancialApplicationViewModel vm) { var application = await _applyApiClient.GetApplication(vm.ApplicationId); if (application is null) { return(RedirectToAction(nameof(OpenApplications))); } if (ModelState.IsValid) { var financialReviewDetails = new FinancialReviewDetails { GradedBy = _contextAccessor.HttpContext.User.UserDisplayName(), GradedDateTime = DateTime.UtcNow, SelectedGrade = vm.FinancialReviewDetails.SelectedGrade, FinancialDueDate = GetFinancialDueDate(vm), Comments = GetFinancialReviewComments(vm), ExternalComments = GetFinancialReviewExternalComments(vm) }; await _applyApiClient.ReturnFinancialReview(vm.ApplicationId, financialReviewDetails); return(RedirectToAction(nameof(Graded), new { vm.ApplicationId })); } else { var newvm = await CreateRoatpFinancialApplicationViewModel(application); newvm.ApplicantEmailAddress = vm.ApplicantEmailAddress; newvm.InadequateComments = vm.InadequateComments; newvm.InadequateExternalComments = vm.InadequateExternalComments; newvm.ClarificationComments = vm.ClarificationComments; // For now, only replace selected grade with whatever was selected if (vm.FinancialReviewDetails != null) { newvm.FinancialReviewDetails.SelectedGrade = vm.FinancialReviewDetails.SelectedGrade; } return(View("~/Views/Roatp/Apply/Financial/Application.cshtml", newvm)); } }
private static DateTime?GetFinancialDueDate(RoatpFinancialApplicationViewModel vm) { if (vm is null) { return(null); } switch (vm?.FinancialReviewDetails?.SelectedGrade) { case FinancialApplicationSelectedGrade.Outstanding: return(vm.OutstandingFinancialDueDate?.ToDateTime()); case FinancialApplicationSelectedGrade.Good: return(vm.GoodFinancialDueDate?.ToDateTime()); case FinancialApplicationSelectedGrade.Satisfactory: return(vm.SatisfactoryFinancialDueDate?.ToDateTime()); default: return(null); } }
public void Validator_rejects_FinancialDueDate_before_today_when_graded_Satisfactory() { var _viewModel = new RoatpFinancialApplicationViewModel { SatisfactoryFinancialDueDate = new FinancialDueDate { Day = DateTime.Today.AddDays(-1).Day.ToString(), Month = DateTime.Today.Month.ToString(), Year = DateTime.Today.Year.ToString() }, FinancialReviewDetails = new FinancialReviewDetails { SelectedGrade = FinancialApplicationSelectedGrade.Satisfactory, } }; var validationResponse = _validator.Validate(_viewModel); var error = validationResponse.Errors.FirstOrDefault(x => x.PropertyName == "SatisfactoryFinancialDueDate"); error.Should().NotBeNull(); }
public void Validator_rejects_invalid_FinancialDueDate_when_graded_Good() { var _viewModel = new RoatpFinancialApplicationViewModel { GoodFinancialDueDate = new FinancialDueDate { Day = "999", Month = DateTime.Today.Month.ToString(), Year = DateTime.Today.Year.ToString() }, FinancialReviewDetails = new FinancialReviewDetails { SelectedGrade = FinancialApplicationSelectedGrade.Good, } }; var validationResponse = _validator.Validate(_viewModel); var error = validationResponse.Errors.FirstOrDefault(x => x.PropertyName == "GoodFinancialDueDate"); error.Should().NotBeNull(); }
public void Validator_rejects_unparseable_FinancialDueDate_when_graded_Good() { var _viewModel = new RoatpFinancialApplicationViewModel { GoodFinancialDueDate = new FinancialDueDate { Day = "test", Month = "test", Year = "test" }, FinancialReviewDetails = new FinancialReviewDetails { SelectedGrade = FinancialApplicationSelectedGrade.Good, } }; var validationResponse = _validator.Validate(_viewModel); var error = validationResponse.Errors.FirstOrDefault(x => x.PropertyName == "GoodFinancialDueDate"); error.Should().NotBeNull(); }
private static RoatpFinancialClarificationViewModel ConvertFinancialApplicationToFinancialClarificationViewModel(RoatpFinancialApplicationViewModel vm, string internalComments) { var viewModel = new RoatpFinancialClarificationViewModel { ClarificationComments = vm.ClarificationComments, InadequateComments = vm.InadequateComments, InadequateExternalComments = vm.InadequateExternalComments, ApplicantEmailAddress = vm.ApplicantEmailAddress, FinancialReviewDetails = vm.FinancialReviewDetails, ApplicationId = vm.ApplicationId, ApplicationReference = vm.ApplicationReference, ApplicationRoute = vm.ApplicationRoute, DeclaredInApplication = vm.DeclaredInApplication, Sections = vm.Sections, OutstandingFinancialDueDate = vm.OutstandingFinancialDueDate, GoodFinancialDueDate = vm.GoodFinancialDueDate, SatisfactoryFinancialDueDate = vm.SatisfactoryFinancialDueDate, InternalComments = internalComments, Ukprn = vm.Ukprn, OrganisationName = vm.OrganisationName, SubmittedDate = vm.SubmittedDate }; return(viewModel); }