From 4238e2a4f3a418c8d8cb68f8efdc59b83ce768d8 Mon Sep 17 00:00:00 2001 From: Bjarne Fyrstenborg Date: Thu, 2 Jun 2022 15:47:47 +0200 Subject: [PATCH] Simplify code in UmbracoViewPage (#12528) --- src/Umbraco.Web.Common/Views/UmbracoViewPage.cs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Umbraco.Web.Common/Views/UmbracoViewPage.cs b/src/Umbraco.Web.Common/Views/UmbracoViewPage.cs index b1ac11c77d..9ac8d917f5 100644 --- a/src/Umbraco.Web.Common/Views/UmbracoViewPage.cs +++ b/src/Umbraco.Web.Common/Views/UmbracoViewPage.cs @@ -39,21 +39,19 @@ public abstract class UmbracoViewPage : RazorPage return _helper; } + _helper = Context.RequestServices.GetRequiredService(); + TModel model = ViewData.Model; var content = model as IPublishedContent; + if (content is null && model is IContentModel contentModel) { content = contentModel.Content; } - if (content is null) - { - content = UmbracoContext?.PublishedRequest?.PublishedContent; - } + content ??= UmbracoContext?.PublishedRequest?.PublishedContent; - _helper = Context.RequestServices.GetRequiredService(); - - if (!(content is null)) + if (content is not null) { _helper.AssignedContentItem = content; }