public async Task When_ConfirmApplicationAction_is_Empty() { _viewModel = new RoatpWithdrawApplicationViewModel { ConfirmApplicationAction = string.Empty }; var result = await _validator.Validate(_viewModel); Assert.IsTrue(result.Errors.Any()); Assert.AreEqual("ConfirmApplicationActionYes", result.Errors.First().Field); }
public async Task <IActionResult> ConfirmWithdrawApplication(Guid applicationId, RoatpWithdrawApplicationViewModel viewModel) { var application = await _applyApiClient.GetApplication(applicationId); var oversightDetails = await _applyApiClient.GetOversightDetails(applicationId); if (application is null) { return(RedirectToAction(nameof(RoatpGatewayController.NewApplications), "RoatpGateway")); } else if (oversightDetails.OversightStatus != OversightReviewStatus.None || application.ApplicationStatus == ApplicationStatus.Withdrawn || application.ApplicationStatus == ApplicationStatus.Removed) { return(RedirectToAction(nameof(RoatpGatewayController.ViewApplication), "RoatpGateway", new { applicationId })); } var validationResponse = await _withdrawApplicationValidator.Validate(viewModel); if (validationResponse.Errors != null && validationResponse.Errors.Any()) { _applicationActionsOrchestrator.ProcessWithdrawApplicationViewModelOnError(viewModel, validationResponse); return(View("~/Views/Gateway/ConfirmWithdrawApplication.cshtml", viewModel)); } else if (viewModel.ConfirmApplicationAction == HtmlAndCssElements.RadioButtonValueYes) { var username = HttpContext.User.UserDisplayName(); var userId = HttpContext.User.UserId(); await _applyApiClient.WithdrawApplication(viewModel.ApplicationId, viewModel.OptionYesText, userId, username); viewModel.ApplicationReferenceNumber = application.ApplyData.ApplyDetails.ReferenceNumber; return(View("~/Views/Gateway/ApplicationWithdrawn.cshtml", viewModel)); } else { return(RedirectToAction(nameof(RoatpGatewayController.ViewApplication), "RoatpGateway", new { applicationId })); } }