protected IActionResult CheckParentValidityAndRedirect(FormSection section, int submittedPageId) { var licenceId = Session.GetCurrentLicenceId(); var sectionLength = FormDefinition.GetSectionLength(section); var nextPageId = submittedPageId + 1; if (Session.GetCurrentUserIsAdmin()) { return(RedirectToAction("Licence", "Admin", new { id = licenceId })); } if (nextPageId != sectionLength) { var parent = FindParentSection(section, licenceId); return(parent == null ? RedirectToAction("TaskList", "Licence") : ValidateParentAndRedirect(parent, section, nextPageId)); } return(RedirectToLastAction(section)); }