Organisaties in Twente

Error executing template "Designs/TwenteBranding/QueryPublisher/PartnerArticleList.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.GetTwenteBrandingItemForSearchResultLoopItem(LoopItem baseLoopItem, String culture, PageService pageService, ItemService itemService, Boolean useParent) in D:\agent_2\_work\78\s\TwenteBranding.Repository\Helpers\ItemHelper.cs:line 254
at TwenteBranding.Repository.Helpers.ItemHelper.GetTwenteBrandingItemsFromQueryPublisherLoopItems(List`1 baseLoopItems, String currentPageId, String culture, String currentAreaId, Boolean allowWidgetInsertion, PageService pageService, ItemService itemService, Boolean useParent, QueryPublisherSortEnum sortType) in D:\agent_2\_work\78\s\TwenteBranding.Repository\Helpers\ItemHelper.cs:line 130
at CompiledRazorTemplates.Dynamic.RazorEngine_7fc085dc242a4384b13e69cd550cb7e4.Execute() in D:\inetpub\wwwroot\www.twente.com\Files\Templates\Designs\TwenteBranding\QueryPublisher\PartnerArticleList.cshtml:line 28
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 articleResults = GetLoop("QueryResultItem"); 6 var letterFilter = System.Web.HttpContext.Current.Request.QueryString.Get("l"); 7 var textFilter = System.Web.HttpContext.Current.Request.QueryString.Get("t"); 8 var municipalityFilter = System.Web.HttpContext.Current.Request.QueryString.Get("m"); 9 var searched = !string.IsNullOrWhiteSpace(letterFilter) || !string.IsNullOrWhiteSpace(textFilter) || !string.IsNullOrWhiteSpace(municipalityFilter); 10 11 // set default letter filter to prevent too many results 12 if (!searched) 13 { 14 letterFilter = "A"; 15 } 16 17 var pageService = new Dynamicweb.Content.PageService(); 18 var municipalities = ItemHelper.GetMunicipalityPages(pageService); 19 20 if (articleResults != null && articleResults.Any()) 21 { 22 var itemService = new Dynamicweb.Content.ItemService(); 23 var culture = GetGlobalValue("Global:Area.LongLang"); 24 var currentAreaId = GetGlobalValue("Global:Area.ID"); 25 var currentPageId = GetGlobalValue("Global:Page.ID"); 26 27 // Convert 28 var twenteBrandingItems = ItemHelper.GetTwenteBrandingItemsFromQueryPublisherLoopItems(articleResults, currentPageId, culture, currentAreaId, false, pageService, itemService, true, TwenteBranding.Models.Constants.QueryPublisherSortEnum.QueryPublisherSort); 29 30 // Filter 31 twenteBrandingItems = ItemHelper.FilterPartners(twenteBrandingItems, letterFilter, textFilter, municipalityFilter); 32 33 if (twenteBrandingItems != null && twenteBrandingItems.Any()) 34 { 35 var index = 1; 36 foreach (var item in twenteBrandingItems) 37 { 38 var title = item.Title; 39 var text = item.Text; 40 var hashtag = item.MainHashtag.IsNotNullOrEmpty() ? item.MainHashtag : item.MainHashtagEnglish; 41 var earthIsCalling = item.EarthIsCalling; 42 var detailsUrl = item.DetailsUrl; 43 var backgroundStyle = item.BackgroundStyle; 44 var backgroundImage = item.Image; 45 46 var goalName = item.GoalName; 47 var goalGradientCss = item.GoalGradientCss; 48 var goalIcon = item.GoalIcon; 49 var goalType = item.GoalType; 50 var goalClass = !string.IsNullOrWhiteSpace(detailsUrl) ? item.ClassName : string.Format("{0} no-link", item.ClassName); 51 var goalUrl = item.GoalUrl; 52 53 var partnerLogo = item.PartnerLogo; 54 partnerLogo = $"/Admin/Public/GetImage.ashx?Image={partnerLogo}&Format=webp&Width=200&Height=-1&Quality=100&Crop=0&t=2"; 55 var partnerColor = item.PartnerColor; 56 var partnerIntro = item.PartnerIntro; 57 58 var fontColor = string.IsNullOrWhiteSpace(item.HeaderFontColor) ? "font-color--white" : item.HeaderFontColor; 59 60 if (item.IsPartnerItem) 61 { 62 goalClass += " partner-item"; 63 } 64 65 <div class="item-container item-clickable @goalClass" style="order: @index"> 66 <div class="item lazy" style="@backgroundStyle" data-src="@backgroundImage"> 67 <div class="item-content"> 68 <div class="item-content-text"> 69 70 <h2 class="partner-title @fontColor"><a class="item-link" href="@detailsUrl">@title</a></h2> 71 <h4 class="partner-hashtag @fontColor">@hashtag</h4> 72 <div class="partnerintro @fontColor">@partnerIntro</div> 73 @if (!string.IsNullOrWhiteSpace(partnerLogo)) 74 { 75 <div class="partnerlogo default"><img class="lazy" alt="logo @title" data-src="@partnerLogo" /></div> 76 } 77 78 </div> 79 @*<div class="@goalGradientCss"></div>*@ 80 </div> 81 <div class="partnerlogo partner"> 82 @if (!string.IsNullOrWhiteSpace(partnerLogo)) 83 { 84 <img alt="logo @title" class="lazy" data-src="@partnerLogo"/> 85 } 86 </div> 87 </div> 88 </div> 89 90 91 92 93 index++; 94 } 95 } 96 } 97 98 if (articleResults != null && articleResults.Any() || searched) 99 { 100 101 @SnippetStart("ListFilter") 102 <div class="container filter-container no-horizontal-padding"> 103 <div class="input-group search-bar"> 104 <input type="text" class="form-control" name="textfilter-partners" id="textfilter-partners" placeholder="@Translate("Partners_TextFilterPlaceholder", "Gemeente, stad, bedrijf, branche")" value="@textFilter" /> 105 <span class="input-group-btn"> 106 <button class="btn btn-default icon--search icon-color--gray-4 icon-size--x1" type="button"></button> 107 </span> 108 </div> 109 @if (municipalities != null) 110 { 111 <div> 112 <button class="btn-filter-extended icon--menu-arrow-down icon-size--x1" type="button" data-toggle="collapse" data-target="#filter-extended-search" aria-expanded="false" aria-controls="filter-extended-search">@Translate("Partners_ExtendedSearchButtonText", "Uitgebreid zoeken")</button> 113 </div> 114 } 115 @if (searched) 116 { 117 <div class="d-none d-md-block col-md-4"> 118 <button class="btn btn-default icon--reset icon-color--gray-4 icon-size--x3 reset" type="button"></button> 119 </div> 120 } 121 </div> 122 @SnippetEnd("ListFilter") 123 124 @SnippetStart("ListFilterExtended") 125 <div class="@(string.IsNullOrWhiteSpace(municipalityFilter) ? "collapse" : "")" id="filter-extended-search"> 126 <div class="container extended-filter-container"> 127 @if (municipalities != null && municipalities.Any()) 128 { 129 <h3>@Translate("Partners_ExtendedSearchMunicipalitiesTitle", "Gemeenten")</h3> 130 <div class="grid extended-filter-grid cols-3"> 131 @foreach (var municipality in municipalities) 132 { 133 var id = string.Format("Municipality_{0}", municipality.ItemId); 134 var isChecked = !string.IsNullOrWhiteSpace(municipalityFilter) && municipalityFilter.UrlDecode().Contains(municipality.MenuText); 135 <div class="form-check"> 136 <input class="form-check-input" type="checkbox" value="@municipality.MenuText.UrlEncode()" id="@municipality.ItemId" name="Municipality" @(isChecked ? "checked" : "")> 137 <label class="form-check-label" for="@municipality.ItemId">@municipality.MenuText</label> 138 </div> 139 } 140 </div> 141 <div class="filter-buttons"> 142 <button class="btn-filter-show">@Translate("Partners_ShowResultsButtonText", "Toon resultaten")</button> 143 <button class="btn-filter-clear reset">@Translate("Partners_ClearFiltersButtonText", "Wis filters")</button> 144 </div> 145 } 146 </div> 147 </div> 148 @SnippetEnd("ListFilterExtended") 149 150 151 @SnippetStart("ListFilter2") 152 if (string.IsNullOrWhiteSpace(textFilter) && string.IsNullOrWhiteSpace(municipalityFilter)) 153 { 154 <div class="startletter-filter"> 155 @for (char c = 'A'; c <= 'Z'; c++) 156 { 157 var letterClass = (!string.IsNullOrWhiteSpace(letterFilter) && letterFilter.ToUpper().Equals(c.ToString())) ? "active" : ""; 158 <span class="letter @letterClass" data-letter="@c">@c</span> 159 } 160 161 @{ 162 var numberdLetterClass = (!string.IsNullOrWhiteSpace(letterFilter) && letterFilter.Equals("0-9")) ? "active" : ""; 163 <span class="letter @numberdLetterClass" data-letter="0-9">0-9</span> 164 } 165 </div> 166 } 167 @SnippetEnd("ListFilter2") 168 169 @SnippetStart("JavascriptBottom") 170 <script> 171 var letterFilter = '@letterFilter'; 172 var municipalityFilter = []; 173 174 function ResetPartnerFilters() { 175 176 // todo: set loading icon? 177 178 var resetUrl = "/Default.aspx?ID=@GetGlobalValue("Global:Page.ID")"; 179 document.location = resetUrl; 180 } 181 182 function FilterPartners() { 183 184 // todo: set loading icon? 185 186 var filterText = $("#textfilter-partners").val(); 187 188 var filterUrl = "/Default.aspx?ID=@GetGlobalValue("Global:Page.ID")"; 189 190 191 if (filterText !== "") { 192 filterUrl += "&t="; 193 filterUrl += filterText; 194 } else if (municipalityFilter.length !== 0) { 195 filterUrl += "&m="; 196 filterUrl += municipalityFilter; 197 } else { 198 filterUrl += "&l="; 199 filterUrl += letterFilter; 200 } 201 202 document.location = filterUrl; 203 } 204 205 $('#textfilter-partners').bind("enterKey", function (e) { 206 FilterPartners(); 207 }); 208 209 $('#textfilter-partners').keyup(function (e) { 210 if (e.keyCode === 13) { 211 $(this).trigger("enterKey"); 212 } 213 }); 214 215 $(".letter") 216 .off("click").on("click", function () { 217 letterFilter = $(this).attr("data-letter"); 218 FilterPartners(); 219 }); 220 221 $(".search-bar button") 222 .off("click").on("click", function () { 223 FilterPartners(); 224 }); 225 226 $(".form-check-input") 227 .off("click").on("click", function () { 228 $("#textfilter-partners").val(""); 229 }); 230 231 $(".btn-filter-show") 232 .off("click").on("click", function () { 233 municipalityFilter = []; 234 $('input.form-check-input:checked', ".extended-filter-container").each(function () { 235 console.log("add:" + this.value); 236 municipalityFilter.push(this.value); 237 }); 238 FilterPartners(); 239 }); 240 241 $("button.reset") 242 .off("click").on("click", function () { 243 ResetPartnerFilters(); 244 }); 245 246 </script> 247 @SnippetEnd("JavascriptBottom") 248 } 249 }