Error executing template "Designs/Advania/Paragraph/ProductListing.cshtml"
System.ArgumentNullException: Value cannot be null.
Parameter name: source
   at System.Linq.Enumerable.Select[TSource,TResult](IEnumerable`1 source, Func`2 selector)
   at CompiledRazorTemplates.Dynamic.RazorEngine_cf9c9de5acbf495d9e67b6d61b781ed1.Execute() in E:\Octopus\Applications\beta-vefverslun.advania.is\Files\Templates\Designs\Advania\Paragraph\ProductListing.cshtml:line 15
   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 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using Newtonsoft.Json; 3 @using System.Linq; 4 5 @using System.Collections.Generic; 6 @using Newtonsoft.Json.Serialization; 7 8 9 @{ 10 11 string cardcolor = Model.Item.GetString("Card_Color"); 12 string backgroundcolor = Model.Item.GetString("Background_Color"); 13 14 var productListingCardFields = Model.Item.Fields.FirstOrDefault(f => f.SystemName == "Card").Value as IEnumerable<Dynamicweb.Frontend.ItemViewModel>; 15 var productListingCards = productListingCardFields.Select(fl => fl.Fields).ToList(); 16 17 List<dynamic> formattedCards = new List<dynamic>(); 18 19 foreach (var slide in productListingCards) 20 { 21 var iconPaths = slide.FirstOrDefault(f => f.SystemName == "Card_Icon").Value as IEnumerable<dynamic>; 22 var iconPath = iconPaths.FirstOrDefault(); 23 24 25 26 if (iconPath != null) 27 { 28 var formattedCard = new 29 { 30 title = slide.FirstOrDefault(f => f.SystemName == "Card_Title").Value as string, 31 paragraph = slide.FirstOrDefault(f => f.SystemName == "Card_Paragraph").Value as string, 32 linkTitle = slide.FirstOrDefault(f => f.SystemName == "Card_Link_Title").Value as string, 33 linkPath = slide.FirstOrDefault(f => f.SystemName == "Card_Link_Path").Value as Object, 34 iconPath = iconPath, 35 }; 36 formattedCards.Add(formattedCard); 37 } 38 } 39 40 var settings = new JsonSerializerSettings 41 { 42 ContractResolver = new CamelCasePropertyNamesContractResolver() 43 }; 44 45 var listJson = JsonConvert.SerializeObject(formattedCards, settings); 46 } 47 48 <product-listing cardcolor="@cardcolor" 49 backgroundcolor="@backgroundcolor" 50 :cards='@listJson'> 51 </product-listing> 52
Error executing template "Designs/Advania/Paragraph/ProductListing.cshtml"
System.ArgumentNullException: Value cannot be null.
Parameter name: source
   at System.Linq.Enumerable.Select[TSource,TResult](IEnumerable`1 source, Func`2 selector)
   at CompiledRazorTemplates.Dynamic.RazorEngine_cf9c9de5acbf495d9e67b6d61b781ed1.Execute() in E:\Octopus\Applications\beta-vefverslun.advania.is\Files\Templates\Designs\Advania\Paragraph\ProductListing.cshtml:line 15
   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 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using Newtonsoft.Json; 3 @using System.Linq; 4 5 @using System.Collections.Generic; 6 @using Newtonsoft.Json.Serialization; 7 8 9 @{ 10 11 string cardcolor = Model.Item.GetString("Card_Color"); 12 string backgroundcolor = Model.Item.GetString("Background_Color"); 13 14 var productListingCardFields = Model.Item.Fields.FirstOrDefault(f => f.SystemName == "Card").Value as IEnumerable<Dynamicweb.Frontend.ItemViewModel>; 15 var productListingCards = productListingCardFields.Select(fl => fl.Fields).ToList(); 16 17 List<dynamic> formattedCards = new List<dynamic>(); 18 19 foreach (var slide in productListingCards) 20 { 21 var iconPaths = slide.FirstOrDefault(f => f.SystemName == "Card_Icon").Value as IEnumerable<dynamic>; 22 var iconPath = iconPaths.FirstOrDefault(); 23 24 25 26 if (iconPath != null) 27 { 28 var formattedCard = new 29 { 30 title = slide.FirstOrDefault(f => f.SystemName == "Card_Title").Value as string, 31 paragraph = slide.FirstOrDefault(f => f.SystemName == "Card_Paragraph").Value as string, 32 linkTitle = slide.FirstOrDefault(f => f.SystemName == "Card_Link_Title").Value as string, 33 linkPath = slide.FirstOrDefault(f => f.SystemName == "Card_Link_Path").Value as Object, 34 iconPath = iconPath, 35 }; 36 formattedCards.Add(formattedCard); 37 } 38 } 39 40 var settings = new JsonSerializerSettings 41 { 42 ContractResolver = new CamelCasePropertyNamesContractResolver() 43 }; 44 45 var listJson = JsonConvert.SerializeObject(formattedCards, settings); 46 } 47 48 <product-listing cardcolor="@cardcolor" 49 backgroundcolor="@backgroundcolor" 50 :cards='@listJson'> 51 </product-listing> 52