public async Task <IActionResult> Version(CertificateVersionViewModel vm) { // After selecting version, retrieve individual standard for version number vm.Version = (await ApiClient.GetStandardVersion(vm.StandardUId))?.Version; return(await SaveViewModel(vm, returnToIfModelNotValid : "~/Views/CertificateAmend/Version.cshtml", nextAction : RedirectToAction("Check", "CertificateAmend", new { certificateId = vm.Id }), action : CertificateActions.Version)); }
public async Task WhenPostingToSelectAVersion_AndEpaoIsNotApprovedForSelectedVersion_ThenRedirectToNotApprovedToAssessPage(CertificateVersionViewModel vm, StandardVersion standardVersion, CertificateSession session) { var sessionString = JsonConvert.SerializeObject(session); _mockSessionService.Setup(s => s.Get(nameof(CertificateSession))).Returns(sessionString); var expectedValue = true; _mockSessionService.Setup(s => s.TryGet("RedirectToCheck", out expectedValue)).Returns(true); var approvedVersions = new List <StandardVersion>(); _mockStandardVersionClient.Setup(s => s.GetStandardVersionById(vm.StandardUId)).ReturnsAsync(standardVersion); _mockStandardVersionClient.Setup(s => s.GetEpaoRegisteredStandardVersions(EpaoId, session.StandardCode)).ReturnsAsync(approvedVersions); _mockStandardVersionClient.Setup(s => s.GetStandardOptions(vm.StandardUId)).ReturnsAsync(new StandardOptions()); var result = await _certificateVersionController.Version(vm) as RedirectToActionResult; result.ActionName.Should().Be("NotApprovedToAssess"); result.ControllerName.Should().Be("CertificateVersionNotApproved"); }