public IActionResult Prompt(int currentIndex = 0) { var amendment = GetAmendment(); if (amendment == null) { return(RedirectToAction("Index", "TaskList")); } var amendmentOutcome = _amendmentService.CreateAmendment(amendment); SaveAmendment(amendment); if (amendmentOutcome.IsComplete || amendmentOutcome.FurtherQuestions == null) { SaveAmendment(amendment); return(RedirectToAction("Confirm", "Amendments")); } var questions = amendmentOutcome.FurtherQuestions.ToList(); SaveQuestions(questions); var promptViewModel = new QuestionViewModel(questions, currentIndex) { PupilDetails = new PupilViewModel(amendment.Pupil) }; return(View("Prompt", promptViewModel)); }
public IActionResult Confirm(ConfirmViewModel viewModel) { var amendment = GetAmendment(); // Ensure steps haven't been manually skipped if (amendment == null) { return(RedirectToAction("Index", "TaskList")); } // Cancel amendment if (!viewModel.ConfirmAmendment) { // Cancel amendment ClearAmendmentAndRelated(); return(RedirectToAction("Index", "TaskList")); } try { amendment.IsUserConfirmed = true; var amendmentOutcome = _amendmentService.CreateAmendment(amendment); // Create amendment and redirect to amendment received page if (amendmentOutcome.IsComplete && amendmentOutcome.IsAmendmentCreated) { ClearAmendmentAndRelated(); var receivedViewModel = new ReceivedViewModel { NewAmendmentId = amendmentOutcome.NewAmendmentId, NewAmendmentRef = amendmentOutcome.NewAmendmentReferenceNumber }; return(RedirectToAction("Received", receivedViewModel)); } return(RedirectToAction("Prompt", "Questions")); } catch (ApiException <ProblemDetails> apiException) { var properties = apiException.Result.AdditionalProperties; dynamic titleContent = properties.Values.Last(); return(View("CustomMessage", new CustomMessageViewModel { Description = properties.Values.First().ToString(), Title = titleContent.errorMessage.ToString(), PupilDetails = new PupilViewModel(amendment.Pupil) })); } }
public AmendmentOutcome CreateAmendment(Amendment amendment) { _cache.Remove(string.Format(GetAmendmentKeyFormat, CheckingWindow, amendment.Urn)); return(_amendmentService.CreateAmendment(amendment)); }