From c9b655e5bca6bb564c4fb07e456fd2b1c36dff0e Mon Sep 17 00:00:00 2001 From: Matt Barton Date: Thu, 19 Dec 2024 13:21:21 +0000 Subject: [PATCH] fix: refactor to remove ternary operators --- .../Navigation/PathwaysNavigationHelper.cs | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/Childrens-Social-Care-CPD/Contentful/Navigation/PathwaysNavigationHelper.cs b/Childrens-Social-Care-CPD/Contentful/Navigation/PathwaysNavigationHelper.cs index cada8d5c..19681fb8 100644 --- a/Childrens-Social-Care-CPD/Contentful/Navigation/PathwaysNavigationHelper.cs +++ b/Childrens-Social-Care-CPD/Contentful/Navigation/PathwaysNavigationHelper.cs @@ -55,11 +55,19 @@ public PathwaysNavigationHelper(Content page) switch (page.PageType) { case PageType.PathwaysOverviewPage: + string url = "/"; + if (page.PathwaysModule?.ContentsPage != null) + { + url += page.PathwaysModule.ContentsPage.Id; + } + else + { + url += GetFirstSectionFirstPageId(page); + } + this._next = new NavigationLocation { - Url = "/" + (page.PathwaysModule?.ContentsPage == null - ? GetFirstSectionFirstPageId(page) - : page.PathwaysModule.ContentsPage.Id) + Url = url }; break; @@ -167,12 +175,20 @@ private void SetTrainingPagePreviousNavigation(int pageCounter, int sectionCount { // first page in first section, previous should navigate back to contents page // or overview page if there is no contents page + string url = "/"; + if (page.PathwaysModule?.ContentsPage != null) + { + url += page.PathwaysModule.ContentsPage.Id; + } + else + { + url += page.PathwaysModule.OverviewPage?.Id; + } + this._previous = new NavigationLocation { Name = "Previous", - Url = "/" + (page.PathwaysModule?.ContentsPage != null - ? page.PathwaysModule.ContentsPage.Id - : page.PathwaysModule.OverviewPage?.Id) + Url = url }; } }