public async Task <IActionResult> ConfirmRemoveApplication(Guid applicationId, RoatpRemoveApplicationViewModel viewModel) { var application = await _applyApiClient.GetApplication(applicationId); if (application is null) { return(RedirectToAction(nameof(RoatpGatewayController.NewApplications), "RoatpGateway")); } else if (application.ApplicationStatus == ApplicationStatus.Removed) { return(RedirectToAction(nameof(RoatpGatewayController.ViewApplication), "RoatpGateway", new { applicationId })); } var validationResponse = await _removeApplicationValidator.Validate(viewModel); if (validationResponse.Errors != null && validationResponse.Errors.Any()) { _applicationActionsOrchestrator.ProcessRemoveApplicationViewModelOnError(viewModel, validationResponse); return(View("~/Views/Gateway/ConfirmRemoveApplication.cshtml", viewModel)); } else if (viewModel.ConfirmApplicationAction == HtmlAndCssElements.RadioButtonValueYes) { var username = HttpContext.User.UserDisplayName(); var userId = HttpContext.User.UserId(); await _applyApiClient.RemoveApplication(viewModel.ApplicationId, viewModel.OptionYesText, viewModel.OptionYesTextExternal, userId, username); viewModel.ApplicationReferenceNumber = application.ApplyData.ApplyDetails.ReferenceNumber; return(View("~/Views/Gateway/ApplicationRemoved.cshtml", viewModel)); } else { return(RedirectToAction(nameof(RoatpGatewayController.ViewApplication), "RoatpGateway", new { applicationId })); } }
public async Task When_ConfirmApplicationAction_is_Empty() { _viewModel = new RoatpRemoveApplicationViewModel { ConfirmApplicationAction = string.Empty }; var result = await _validator.Validate(_viewModel); Assert.IsTrue(result.Errors.Any()); Assert.AreEqual("ConfirmApplicationActionYes", result.Errors.First().Field); }