Skip to content

Commit

Permalink
Update ContentController.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
killij committed Nov 8, 2023
1 parent 0e2f042 commit c979df0
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions Childrens-Social-Care-CPD/Controllers/ContentController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,28 +45,24 @@ private async Task<Content> FetchPageContentAsync(string contentId, Cancellation
public async Task<IActionResult> Index(CancellationToken cancellationToken, string pageName = "home", bool preferenceSet = false)
{
pageName = pageName?.TrimEnd('/');
var pageContent = await FetchPageContentAsync(pageName, cancellationToken);
if (pageContent == null)
var content = await FetchPageContentAsync(pageName, cancellationToken);
if (content == null)
{
return NotFound();
}

var contextModel = new ContextModel(
Id: pageContent.Id,
Title: pageContent.Title,
Id: content.Id,
Title: content.Title,
PageName: pageName,
Category: pageContent.Category,
UseContainers: pageContent.SideMenu == null,
Category: content.Category,
UseContainers: content.SideMenu == null,
PreferenceSet: preferenceSet,
BackLink: pageContent.BackLink);
BackLink: content.BackLink);

ViewData["ContextModel"] = contextModel;
ViewData["StateModel"] = new StateModel();

return pageContent.ContentType switch
{
ContentTypes.Resource => View("Resource", pageContent),
_ => View(pageContent)
};
return View(content);
}
}

0 comments on commit c979df0

Please sign in to comment.