#gezondheid

Error executing template "Designs/TwenteBranding/ItemPublisher/List/HashtagArticleList.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
at Dynamicweb.Content.ItemService.GetItemByPageId(Int32 pageId, Boolean draft, DateTime previewDate)
at TwenteBranding.Repository.Helpers.ItemHelper.<>c__DisplayClass27_0.b__0(Page y) in D:\agent_2\_work\78\s\TwenteBranding.Repository\Helpers\ItemHelper.cs:line 1810
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Linq.Enumerable.Count[TSource](IEnumerable`1 source, Func`2 predicate)
at TwenteBranding.Repository.Helpers.ItemHelper.GetJobCountByPartner(Int32 partnerId, PageService pageService, ItemService itemService) in D:\agent_2\_work\78\s\TwenteBranding.Repository\Helpers\ItemHelper.cs:line 1812
at TwenteBranding.Repository.Helpers.ItemHelper.GetTwenteBrandingItemForItem(String instanceType, Item item, String culture, PageService pageService, Boolean useParent) in D:\agent_2\_work\78\s\TwenteBranding.Repository\Helpers\ItemHelper.cs:line 784
at TwenteBranding.Repository.Helpers.ItemHelper.GetTwenteBrandingItemForLoopItem(LoopItem baseLoopItem, String culture, PageService pageService, ItemService itemService, Boolean useParent) in D:\agent_2\_work\78\s\TwenteBranding.Repository\Helpers\ItemHelper.cs:line 102
at TwenteBranding.Repository.Helpers.ItemHelper.GetTwenteBrandingItemsFromLoopItems(List`1 baseLoopItems, String currentPageId, String culture, String currentAreaId, Boolean allowWidgetInsertion, PageService pageService, ItemService itemService, Boolean useParent) in D:\agent_2\_work\78\s\TwenteBranding.Repository\Helpers\ItemHelper.cs:line 48
at CompiledRazorTemplates.Dynamic.RazorEngine_0ac69a8283b54d7d8f26dc70577d0048.Execute() in D:\inetpub\wwwroot\www.twente.com\Files\Templates\Designs\TwenteBranding\ItemPublisher\List\HashtagArticleList.cshtml:line 21
at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.b__0(TextWriter writer)
at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
at Dynamicweb.Rendering.Template.RenderRazorTemplate()

1 @using Dynamicweb.Core 2 @using TwenteBranding.Repository.Helpers 3 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 4 @{ 5 var currentPage = Dynamicweb.Frontend.PageView.Current(); 6 if (currentPage != null && currentPage.Item != null && !string.IsNullOrWhiteSpace(currentPage.Item.Id)) 7 { 8 var hashtagId = currentPage.Item.Id; 9 10 var items = GetLoop("ItemPublisher:Items.List"); 11 if (items != null && items.Any()) 12 { 13 var pageService = new Dynamicweb.Content.PageService(); 14 var itemService = new Dynamicweb.Content.ItemService(); 15 16 var culture = GetGlobalValue("Global:Area.LongLang"); 17 var currentAreaId = GetGlobalValue("Global:Area.ID"); 18 var currentPageId = GetGlobalValue("Global:Page.ID"); 19 20 // Convert 21 var twenteBrandingItems = ItemHelper.GetTwenteBrandingItemsFromLoopItems(items, currentPageId, culture, currentAreaId, true, pageService, itemService); 22 23 // Filter 24 twenteBrandingItems = ItemHelper.FilterByHashtag(twenteBrandingItems, hashtagId); 25 26 if (twenteBrandingItems != null && twenteBrandingItems.Any()) 27 { 28 var index = 1; 29 foreach (var item in twenteBrandingItems) 30 { 31 var title = item.Title; 32 var text = item.Text; 33 var hashtag = item.MainHashtag.IsNotNullOrEmpty() ? item.MainHashtag : item.MainHashtagEnglish; 34 var earthIsCalling = item.EarthIsCalling; 35 var detailsUrl = item.DetailsUrl; 36 37 var backgroundStyle = item.BackgroundStyle; 38 var backgroundImage = item.Image; 39 40 var goalName = item.GoalName; 41 var goalGradientCss = item.GoalGradientCss; 42 var goalIcon = item.GoalIcon; 43 var goalIconHeader = item.GoalIconHeader; 44 var goalIconOther = item.GoalIconOther; 45 var goalType = item.GoalType; 46 var goalClass = !string.IsNullOrWhiteSpace(detailsUrl) ? item.ClassName : string.Format("{0} no-link", item.ClassName); 47 var goalUrl = item.GoalUrl; 48 49 var fontColor = string.IsNullOrWhiteSpace(item.HeaderFontColor) ? "font-color--white" : item.HeaderFontColor; 50 51 switch (goalType) 52 { 53 case TwenteBranding.Models.Constants.StringConstants.ItemInstanceType.CallToActionArticle: 54 <div class="item-container @goalClass item-clickable" style="order: @index"> 55 56 <div> 57 <div class="item" style="@backgroundStyle" data-src="@backgroundImage"> 58 59 @TwenteBranding.Repository.Helpers.ItemHelper.GetTileIconLink(goalIcon, goalUrl) 60 61 @*<h4 class="item-hashtag sub-header font-color--white">@hashtag</h4>*@ 62 63 <div class="item-content"> 64 <div class="item-content-text"> 65 <div class="call-to-action"> 66 <a class="item-link" href="@detailsUrl"> 67 @text 68 </a> 69 </div> 70 </div> 71 <div class="@goalGradientCss"></div> 72 </div> 73 </div> 74 </div> 75 76 </div> 77 break; 78 case TwenteBranding.Models.Constants.StringConstants.ItemInstanceType.EventArticle: 79 80 var eventOrganizer = item.EventOrganizer; 81 var eventCity = item.EventCity; 82 var eventLocation = item.EventLocation; 83 var eventPeriod = item.EventPeriod; 84 var eventPeriodDatesOnly = item.EventPeriodDatesOnly; 85 var eventPeriodTimesOnly = item.EventPeriodTimesOnly; 86 var eventInfo = FormatHelper.FormatEventInfo(eventCity, eventPeriodTimesOnly, eventOrganizer, Translate("EventOrganizer", "Organizer")); 87 88 <div class="item-container item-clickable item-eventarticle @goalClass" style="order: @index"> 89 <div> 90 <div class="item lazy" data-src="@backgroundImage" style="@backgroundStyle"> 91 92 @TwenteBranding.Repository.Helpers.ItemHelper.GetTileIconLink(goalIcon, goalUrl) 93 94 <h4 class="item-hashtag sub-header font-color--white">@hashtag</h4> 95 96 <div class="item-content"> 97 <div class="item-content-text"> 98 <h4 class="event-dateperiod font-color--white italic">@eventPeriodDatesOnly</h4> 99 </div> 100 <div class="@goalGradientCss item-gradient"></div> 101 </div> 102 103 </div> 104 105 <div class="event-details"> 106 <h2 class="event-title"> 107 <a class="item-link item-article" href="@detailsUrl"> 108 @title.ClipLength(50) 109 </a> 110 </h2> 111 @if (!string.IsNullOrWhiteSpace(eventInfo)) 112 { 113 <div class="event-info">@eventInfo</div> 114 } 115 </div> 116 </div> 117 118 </div> 119 break; 120 case TwenteBranding.Models.Constants.StringConstants.ItemInstanceType.JobOfferArticle: 121 122 var jobProduct = item.JobProduct; 123 var jobDiscipline = item.JobDiscipline; 124 var jobEducationalAttainment = item.JobEducationalAttainment; 125 var jobIntro = item.JobIntro; 126 var jobIntroInformationShort = item.JobIntroInformationShort; 127 var jobCompanyLogo = item.JobCompanyLogo; 128 jobCompanyLogo = $"/Admin/Public/GetImage.ashx?Image={jobCompanyLogo}&Format=webp&Width=200&Height=-1&Quality=100&Crop=0&t=2"; 129 130 var jobIsFeatured = item.JobIsFeatured; 131 var jobCompanyIsPartner = item.JobCompanyIsPartner; 132 133 if (jobIsFeatured) 134 { 135 <div class="item-container item-clickable item-jobofferfeaturedarticle featured @goalClass" style="order: @index"> 136 <div class="item lazy" style="@backgroundStyle" data-src="@backgroundImage"> 137 138 @if (!string.IsNullOrWhiteSpace(jobCompanyLogo)) 139 { 140 <div class="joboffer-companylogo"><img alt="logo @title" class="lazy" data-src="@jobCompanyLogo" /></div> 141 } 142 else 143 { 144 @*<h4 class="item-hashtag sub-header font-color-joboffer">@hashtag</h4>*@ 145 <div class="joboffer-companylogo"></div> 146 147 } 148 149 <div class="item-content"> 150 <div class="item-content-text"> 151 152 <h2 class="joboffer-title font-color-joboffer"> 153 <a class="item-link" href="@detailsUrl"> 154 @title 155 </a> 156 </h2> 157 158 @{ 159 goalGradientCss = "no-gradient"; 160 var jobOfferInfo = TwenteBranding.Repository.Helpers.ItemHelper.CreateJobOfferInfoLine(culture, jobProduct, jobDiscipline, jobEducationalAttainment, jobIsFeatured); 161 162 <div class="joboffer-info font-color-joboffer"> 163 @jobOfferInfo 164 @jobIntroInformationShort 165 </div> 166 } 167 </div> 168 <div class="@goalGradientCss"></div> 169 </div> 170 </div> 171 </div> 172 } 173 else 174 { 175 <div class="item-container item-clickable item-jobofferarticle @goalClass default" style="order: @index"> 176 <div class="item"> 177 <div class="item-content"> 178 <div class="item-content-text"> 179 <h2 class="joboffer-title font-color--black"> 180 <a class="item-link" href="@detailsUrl">@title</a> 181 </h2> 182 183 @{ 184 if (jobProduct != null || jobDiscipline != null || jobEducationalAttainment != null) 185 { 186 var jobOfferInfo = TwenteBranding.Repository.Helpers.ItemHelper.CreateJobOfferInfoLine(culture, jobProduct, jobDiscipline, jobEducationalAttainment, jobIsFeatured); 187 188 <div class="joboffer-intro font-color--black"> 189 @jobOfferInfo 190 @jobIntroInformationShort 191 </div> 192 193 if (!string.IsNullOrWhiteSpace(jobCompanyLogo) && jobCompanyIsPartner) 194 { 195 <div class="joboffer-companylogo"> 196 <img alt="logo @title" class="lazy" data-src="@jobCompanyLogo"/> 197 </div> 198 } 199 } 200 } 201 </div> 202 </div> 203 </div> 204 </div> 205 } 206 207 break; 208 case TwenteBranding.Models.Constants.StringConstants.ItemInstanceType.VideoArticle: 209 210 var video = item.Video; 211 212 <div class="item-container item-videoarticle item-clickable @goalClass" style="order: @index"> 213 <div> 214 <div class="item lazy" style="@backgroundStyle" data-src="@backgroundImage"> 215 216 @TwenteBranding.Repository.Helpers.ItemHelper.GetTileIconLink(goalIcon, goalUrl) 217 218 <h4 class="item-hashtag sub-header font-color--white">@hashtag</h4> 219 220 <div class="video-icon icon--video icon-size--x4"></div> 221 222 <div class="item-content"> 223 <div class="item-content-text"> 224 <h2 class="font-color--white"> 225 <a class="item-link item-article" href="@detailsUrl">@title</a> 226 </h2> 227 </div> 228 <div class="@goalGradientCss"></div> 229 </div> 230 231 </div> 232 </div> 233 </div> 234 break; 235 case TwenteBranding.Models.Constants.StringConstants.ItemInstanceType.PartnerArticle: 236 237 var partnerLogo = item.PartnerLogo; 238 partnerLogo = $"/Admin/Public/GetImage.ashx?Image={partnerLogo}&Format=webp&Width=200&Height=-1&Quality=100&Crop=0&t=2"; 239 var partnerColor = item.PartnerColor; 240 var partnerIntro = item.PartnerIntro; 241 242 <div class="item-container item-clickable @goalClass" style="order: @index"> 243 <div class="item lazy" style="@backgroundStyle" data-src="@backgroundImage"> 244 <div class="item-content"> 245 <div class="item-content-text"> 246 247 <h2 class="partner-title @fontColor"><a class="item-link" href="@detailsUrl">@title</a></h2> 248 <h4 class="partner-hashtag @fontColor">@hashtag</h4> 249 <div class="partnerintro @fontColor">@partnerIntro</div> 250 @if (!string.IsNullOrWhiteSpace(partnerLogo)) 251 { 252 <div class="partnerlogo default"><img class="lazy" alt="logo @title" data-src="@partnerLogo" /></div> 253 } 254 255 </div> 256 @*<div class="@goalGradientCss"></div>*@ 257 </div> 258 <div class="partnerlogo partner"> 259 @if (!string.IsNullOrWhiteSpace(partnerLogo)) 260 { 261 <img alt="logo @title" class="lazy" data-src="@partnerLogo"/> 262 } 263 </div> 264 </div> 265 </div> 266 267 268 269 break; 270 default: 271 <div class="item-container item-basearticle item-clickable @goalClass" style="order: @index"> 272 <div> 273 <div class="item lazy" style="@backgroundStyle" data-src="@backgroundImage"> 274 @if (earthIsCalling) 275 { 276 @TwenteBranding.Repository.Helpers.ItemHelper.GetTileIconLink(goalIconHeader, goalUrl, earthIsCalling, goalIconOther) 277 <span class="item-hashtag sub-header font-color--white earth-is-calling">@hashtag</span> 278 } 279 else 280 { 281 @TwenteBranding.Repository.Helpers.ItemHelper.GetTileIconLink(goalIcon, goalUrl, earthIsCalling) 282 <h4 class="item-hashtag sub-header font-color--white">@hashtag</h4> 283 } 284 285 <div class="item-content"> 286 <div class="item-content-text"> 287 <h2 class="font-color--white @(earthIsCalling ? "earth-is-calling" : "")"> 288 <a class="item-link item-article" href="@detailsUrl">@title</a> 289 </h2> 290 </div> 291 <div class="@goalGradientCss"></div> 292 </div> 293 294 </div> 295 </div> 296 </div> 297 break; 298 } 299 300 index++; 301 } 302 } 303 } 304 } 305 else 306 { 307 <p>@Translate("Hashtag_ConfigError", "Configuratie error.")</p> 308 } 309 }