The Pike

Error executing template "Designs/Rapido/QueryPublisher/SpWallOfFameList.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_ecf6b849a62040428e8deed6270844a0.Execute() in D:\dynamicweb.net\Solutions\Smartpage\svendsensport.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\QueryPublisher\SpWallOfFameList.cshtml:line 98
   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.<RunCompile>b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
   at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

1 @using System 2 @using System.Web 3 @using System.Linq 4 @using Dynamicweb; 5 @using Dynamicweb.Data; 6 @using Dynamicweb.Core; 7 @using Dynamicweb.Content; 8 @using Dynamicweb.Content.Items; 9 @using Dynamicweb.Frontend; 10 @using Dynamicweb.Ecommerce.Frontend 11 12 @{ 13 14 var fishRecords = GetLoop("QueryResultItem"); 15 16 Paragraph wallOfFameParagraph = Dynamicweb.Services.Paragraphs.GetParagraphsByItemTypes(new List<string>() { "SpWallOfFame" }).Where(x => x.Page.ID == GetPageIdByNavigationTag("WallOfFame")).FirstOrDefault(); 17 var masterImageFolderPath = Pageview.AreaSettings.GetItem("Custom").GetString("MasterProductImageFolder"); 18 19 var species = ItemList.GetItemListById(Converter.ToInt32(wallOfFameParagraph.Item["SelectSpecies"])); 20 21 var fishCounter = 1; 22 var fishTotal = GetInteger("QueryResult.TotalCount"); 23 24 } 25 26 <div class="grid__col-12 u-padding-top--lg"></div> 27 28 @if (fishRecords.FirstOrDefault() != null) 29 { 30 foreach (var fishRecord in fishRecords.OrderByDescending(i => decimal.Parse(i.GetString("SpFishRecord_Lenght"))).ThenByDescending(i => Converter.ToDateTime(i.GetString("SpFishRecord_Date")))) 31 { 32 var medal = ""; 33 var fishMedal = false; 34 var medalStyle = ""; 35 string imagePath = ""; 36 string prodLink = ""; 37 string prodName = ""; 38 string fishImage = "/Admin/Public/GetImage.ashx?Image=" + fishRecord.GetString("SpFishRecord_Image").Replace("?", "&") + "&Crop=7&width=430&height=240&Format=jpg"; 39 string fishImageLarge = "/Admin/Public/GetImage.ashx?Image=" + fishRecord.GetString("SpFishRecord_Image").Replace("?", "&") + "&Crop=7&width=1200&Format=jpg"; 40 string fishWeight = ""; 41 42 43 if (!string.IsNullOrWhiteSpace(fishRecord.GetString("SpFishRecord_Weight"))) 44 { 45 fishWeight = fishRecord.GetString("SpFishRecord_Weight") + " " + Translate("KG"); 46 } 47 else 48 { 49 fishWeight = Translate("Wall of fame:weight.unknown", "unknown"); 50 } 51 52 53 if (fishCounter == 1) 54 { 55 medal = Translate("Gold"); 56 fishMedal = true; 57 medalStyle = "color: #C9B037; border-left: 5px solid;"; 58 } 59 else if (fishCounter == 2) 60 { 61 medal = Translate("Silver"); 62 fishMedal = true; 63 medalStyle = "color: #A7B9BE; border-left: 5px solid;"; 64 } 65 else if (fishCounter == 3) 66 { 67 medal = Translate("Bronze"); 68 fishMedal = true; 69 medalStyle = "color: #BD8434; border-left: 5px solid;"; 70 } 71 72 if (!string.IsNullOrEmpty(fishRecord.GetString("SpFishRecord_CatchedWith"))) 73 { 74 75 var test = fishRecord.GetValue("SpFishRecord_CatchedWith") as string[]; 76 77 foreach (string testItem in test.Take(1)) 78 { 79 if (testItem.Length > 2) 80 { 81 var prodId = ""; 82 int index = 0; 83 84 if (testItem.Contains(":")) 85 { 86 prodId = testItem.Substring(2).Replace(":", ""); 87 index = testItem.IndexOf(":"); 88 } 89 else 90 { 91 prodId = testItem.Substring(2); 92 index = testItem.Length; 93 } 94 95 prodId = testItem.Substring(2, index - 2); 96 97 var prod = Dynamicweb.Ecommerce.Services.Products.GetProductById(prodId, "", false); 98 prodLink = "/Default.aspx?ID=" + GetPageIdByNavigationTag("ProductsPage") + "&ProductID=" + prod.Id; 99 prodName = prod.Name; 100 101 string[] types = new string[] { ".jpg", ".jpeg", ".png", ".bmp", ".tiff", ".gif" }; 102 foreach (var type in types) 103 { 104 var name = HttpContext.Current.Server.MapPath("~/Files/images/") + masterImageFolderPath + "/" + prod.Number + type; 105 106 107 if (System.IO.File.Exists(HttpContext.Current.Server.MapPath("~/Files/images/") + masterImageFolderPath + "/" + prod.Number + type)) 108 { 109 imagePath = "/Admin/Public/GetImage.ashx?width=100&image=Files/Images/" + masterImageFolderPath + "/" + prod.Number + type; 110 break; 111 } 112 } 113 } 114 } 115 116 } 117 118 <div class="grid__col-12 sp-wall-of-fame-list-item u-no-padding"> 119 <div class="grid__col-xs-4 u-flex-row-wrap u-no-padding"> 120 @*Number*@ 121 @if (fishMedal) 122 { 123 <div class="u-no-padding-x sp-wall-of-fame-list-item__number u-no-padding" style="@medalStyle"> 124 <span class="sp-wall-of-fame-list-item_medal u-uppercase">@medal</span> 125 </div> 126 } 127 else 128 { 129 <div class=" u-no-padding-x sp-wall-of-fame-list-item__number u-no-padding"> 130 <span>@fishCounter</span> 131 </div> 132 } 133 134 @*Image*@ 135 136 <div class="grid__col-auto sp-wall-of-fame-list-item__image sp-image-cover" style="background-image: url('@fishImage')"> 137 <a class="sp-wall-of-fame-list-item__image-link" href="@fishImageLarge" target="_blank"> 138 </a> 139 </div> 140 </div> 141 <div class="grid__col-xs-auto u-flex-row-wrap u-no-padding"> 142 @*Cather*@ 143 <div class="grid__col-xs-auto sp-wall-of-fame-list-item__catcher u-uppercase"> 144 <p>@fishRecord.GetString("SpFishRecord_CatcherName") <i>@fishRecord.GetString("SpFishRecord_Location")</i></p> 145 <span>@fishRecord.GetDate("SpFishRecord_Date").ToString("dd.MM.yyyy")</span> 146 </div> 147 @*Fish info*@ 148 <div class="grid__col-xs-3 sp-wall-of-fame-list-item__fish-info u-brand-color-one--bg"> 149 <div> 150 <span><i class="fas fa-arrows-alt-h"></i>@fishRecord.GetString("SpFishRecord_Lenght") @Translate("CM")</span> 151 </div> 152 <div> 153 <span><i class="fas fa-weight"></i>@fishWeight</span> 154 </div> 155 </div> 156 @* Related product *@ 157 <div class="grid__col-xs-4 u-margin-auto u-position-relative"> 158 <label class="u-bold u-ta-center u-text-dots">@prodName</label> 159 <a href="@prodLink"> 160 <img class="u-margin-auto" src="@imagePath" /> 161 </a> 162 </div> 163 </div> 164 </div> 165 166 if (fishCounter == 3 || fishTotal < 3 && fishTotal == fishCounter) 167 { 168 @RenderSnippet("prizes") 169 170 } 171 fishCounter++; 172 } 173 174 } 175 else 176 { 177 <div class="grid__col-md-12"> 178 <div class="u-uppercase u-color-light u-small-bold u-brand-color-one--bg u-ta-center u-font-size--medium u-font-oswald"> 179 @Translate("Not Found") 180 </div> 181 </div> 182 } 183 184 185 186 187 188 189