Error executing template "Designs/Swift/ecom/productcatalog/partials/list-item.cshtml"System.InvalidOperationException: Sequence contains no elementsat System.Linq.Enumerable.First[TSource](IEnumerable`1 source)at CompiledRazorTemplates.Dynamic.RazorEngine_8cb472b9b81c482086a61e11d8954f87.Execute() in D:\Dynamicweb.NET\Solutions\Sika\Files\Templates\Designs\Swift\ecom\productcatalog\partials\list-item.cshtml:line 82at 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 ViewModelTemplate<ProductViewModel> 2 @using System.Collections.Generic 3 @using System.Linq 4 @using System.Text 5 @using Custom.Extensions 6 @using Dynamicweb.Core 7 @using Dynamicweb.Rendering 8 @using Dynamicweb.Ecommerce.ProductCatalog 9 @using Dynamicweb.Frontend 10 @using Dynamicweb.Frontend.Navigation 11 @using ProductViewModel = Custom.Models.Ecommerce.ProductViewModel 12 13 14 @{ 15 int shopPageId = GetPageIdByNavigationTag("Shop"); 16 string productLink = Model.GetProductLink(shopPageId, true); 17 18 var parms = new Dictionary<string, object>(); 19 string anonymousUsersLimitations = Pageview.AreaSettings.GetRawValueString("AnonymousUsers", ""); 20 bool anonymousUser = Pageview.User == null; 21 bool hideCart = anonymousUser && anonymousUsersLimitations == "cart"; 22 bool hideCartAndPrice = anonymousUser && anonymousUsersLimitations == "cart-price"; 23 24 25 string clickProductLink = $"return clickProductLink('{Model.Id}, {Model.Name}, {Model.VariantName}, {Model.Price.CurrencyCode}, {PriceViewModelExtensions.ToStringInvariant(Model.Price)}, {Model.PrimaryOrDefaultGroup?.Id}, {Model.PrimaryOrDefaultGroup?.Name}')"; 26 //string clickProductLink = "onclick=\"return clickProductLink('" + Model.Id + "', '" + Model.Name + "', '" + Model.VariantName + "', '" + Model.Price.CurrencyCode + "', '" + PriceViewModelExtensions.ToStringInvariant(Model.Price) + "')\""; 27 string itemClassList = "card rounded-4 h-100 border-0 pt-2 px-4"; 28 string imageClassList = "card-img-top ratio ratio-1x1 mb-0 order-3"; 29 string contentClassList = "card-body mb-0 px-0 order-1"; 30 string actionClassList = "card-footer px-0 order-2"; 31 if (Model.Layout == Custom.Constants.ProductListViewModes.ListLayout) 32 { 33 itemClassList = "w-100 px-3 rounded-4 py-2 position-relative"; 34 imageClassList = "col-2 d-flex align-items-center order-1"; 35 contentClassList = "col-5 py-2 text-wrap order-2"; 36 actionClassList = "col-5 py-2 text-wrap order-3"; 37 38 parms.Add("cssClass", "w-100 object-fit-cover"); 39 } 40 else 41 { 42 parms.Add("cssClass", "w-100 h-100 object-fit-cover"); 43 } 44 45 46 List<VariantOptionViewModel> colorOptions = Model.VariantGroups().FirstOrDefault(g => g.Id == "VG1615")?.Options; 47 List<VariantOptionViewModel> sizeOptions = new List<VariantOptionViewModel>((IEnumerable<VariantOptionViewModel>)Model.VariantGroups().FirstOrDefault(g => g.Id != "VG1615")?.Options.OrderBy(o => int.TryParse(o.Name, out int size)) ?? new List<VariantOptionViewModel>()); 48 } 49 <div class="@itemClassList custom-product-list-item js-product [email protected]" data-product-id="@Model.Id" data-variant-id="@Model.VariantId" itemscope itemtype="https://schema.org/Product"> 50 <a href="@productLink" class="stretched-link"></a> 51 @if (Model.Layout == Custom.Constants.ProductListViewModes.ListLayout) 52 { 53 @:<div class="row"> 54 } 55 56 57 <figure class="@imageClassList"> 58 <a onmouseover="swift.Image.swapImage(event)" onmouseout="swift.Image.swapImage(event)" href="@productLink" onclick="@clickProductLink"> 59 @RenderPartial("_partials/image.cshtml", Model.DefaultImage.GetFileViewModel() ?? new Dynamicweb.Frontend.FileViewModel(), parms) 60 </a> 61 </figure> 62 63 <div class="@contentClassList"> 64 <p class="fw-bold mb-1">@Model.Number</p> 65 <div class="d-flex justify-content-between"> 66 <p class="card-text text-truncate mb-1 w-50">@Model.Name</p> 67 68 @if (colorOptions != null) 69 { 70 <ul class="color-list-group"> 71 @foreach (VariantOptionViewModel color in colorOptions) 72 { 73 <li style="background-color: black;" title="@color.Name"><span class="visually-hidden">@color.Name</span></li> 74 } 75 </ul> 76 } 77 </div> 78 <p class="small text-muted"> 79 @Translate("Productlist - Sizes - Text", "Str.:") 80 @if (string.IsNullOrEmpty(Model.VariantId) || Model.VariantId == Model.DefaultVariantId) 81 { 82 <span>@sizeOptions.First().Name - @sizeOptions.Last().Name</span> 83 } 84 else 85 { 86 VariantOptionViewModel sizeVariantOption = sizeOptions.FirstOrDefault(so => Model.VariantId.Contains(so.Id)) ; 87 if (sizeVariantOption != null) 88 { 89 <span>@sizeVariantOption.Name</span> 90 } 91 92 } 93 </p> 94 95 96 97 </div> 98 99100 <div class="@actionClassList">101 @if (!anonymousUser){102 @Model.RenderedHtml.Stock103 }104 <div class="row align-items-center justify-content-end mb-1">105 <span class="fs-6">106 @if (anonymousUser)107 {108 <span class="text-muted fs-8">@Translate("RRP")</span>109 }110 @Model.RenderedHtml.Price111 </span>112 </div>113 </div>114115 @if (Model.Layout == Custom.Constants.ProductListViewModes.ListLayout)116 {117 @:</div>118 }119 </div>120121 <script>122 function clickProductLink(productId, productName, productVariant, productCurrency, productPrice, groupId, groupName) {123 if (typeof gtag !== "undefined") {124 gtag("event", "select_item", {125 item_list_id: groupId ? groupId : "product_list_item_repeater",126 item_list_name: groupName ? groupName : "Product list (Item Repeater)",127 items: [128 {129 item_id: productId,130 item_name: productName,131 currency: productCurrency,132 item_list_id: groupId ? groupId : "product_list_item_repeater",133 item_list_name: groupName ? groupName : "Product list (Item Repeater)",134 item_variant: productVariant,135 price: productPrice136 }137 ]138 });139 }140 }141 </script>142
Error executing template "Designs/Swift/ecom/productcatalog/partials/list-item.cshtml"System.InvalidOperationException: Sequence contains no elementsat System.Linq.Enumerable.First[TSource](IEnumerable`1 source)at CompiledRazorTemplates.Dynamic.RazorEngine_8cb472b9b81c482086a61e11d8954f87.Execute() in D:\Dynamicweb.NET\Solutions\Sika\Files\Templates\Designs\Swift\ecom\productcatalog\partials\list-item.cshtml:line 82at 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 ViewModelTemplate<ProductViewModel> 2 @using System.Collections.Generic 3 @using System.Linq 4 @using System.Text 5 @using Custom.Extensions 6 @using Dynamicweb.Core 7 @using Dynamicweb.Rendering 8 @using Dynamicweb.Ecommerce.ProductCatalog 9 @using Dynamicweb.Frontend 10 @using Dynamicweb.Frontend.Navigation 11 @using ProductViewModel = Custom.Models.Ecommerce.ProductViewModel 12 13 14 @{ 15 int shopPageId = GetPageIdByNavigationTag("Shop"); 16 string productLink = Model.GetProductLink(shopPageId, true); 17 18 var parms = new Dictionary<string, object>(); 19 string anonymousUsersLimitations = Pageview.AreaSettings.GetRawValueString("AnonymousUsers", ""); 20 bool anonymousUser = Pageview.User == null; 21 bool hideCart = anonymousUser && anonymousUsersLimitations == "cart"; 22 bool hideCartAndPrice = anonymousUser && anonymousUsersLimitations == "cart-price"; 23 24 25 string clickProductLink = $"return clickProductLink('{Model.Id}, {Model.Name}, {Model.VariantName}, {Model.Price.CurrencyCode}, {PriceViewModelExtensions.ToStringInvariant(Model.Price)}, {Model.PrimaryOrDefaultGroup?.Id}, {Model.PrimaryOrDefaultGroup?.Name}')"; 26 //string clickProductLink = "onclick=\"return clickProductLink('" + Model.Id + "', '" + Model.Name + "', '" + Model.VariantName + "', '" + Model.Price.CurrencyCode + "', '" + PriceViewModelExtensions.ToStringInvariant(Model.Price) + "')\""; 27 string itemClassList = "card rounded-4 h-100 border-0 pt-2 px-4"; 28 string imageClassList = "card-img-top ratio ratio-1x1 mb-0 order-3"; 29 string contentClassList = "card-body mb-0 px-0 order-1"; 30 string actionClassList = "card-footer px-0 order-2"; 31 if (Model.Layout == Custom.Constants.ProductListViewModes.ListLayout) 32 { 33 itemClassList = "w-100 px-3 rounded-4 py-2 position-relative"; 34 imageClassList = "col-2 d-flex align-items-center order-1"; 35 contentClassList = "col-5 py-2 text-wrap order-2"; 36 actionClassList = "col-5 py-2 text-wrap order-3"; 37 38 parms.Add("cssClass", "w-100 object-fit-cover"); 39 } 40 else 41 { 42 parms.Add("cssClass", "w-100 h-100 object-fit-cover"); 43 } 44 45 46 List<VariantOptionViewModel> colorOptions = Model.VariantGroups().FirstOrDefault(g => g.Id == "VG1615")?.Options; 47 List<VariantOptionViewModel> sizeOptions = new List<VariantOptionViewModel>((IEnumerable<VariantOptionViewModel>)Model.VariantGroups().FirstOrDefault(g => g.Id != "VG1615")?.Options.OrderBy(o => int.TryParse(o.Name, out int size)) ?? new List<VariantOptionViewModel>()); 48 } 49 <div class="@itemClassList custom-product-list-item js-product [email protected]" data-product-id="@Model.Id" data-variant-id="@Model.VariantId" itemscope itemtype="https://schema.org/Product"> 50 <a href="@productLink" class="stretched-link"></a> 51 @if (Model.Layout == Custom.Constants.ProductListViewModes.ListLayout) 52 { 53 @:<div class="row"> 54 } 55 56 57 <figure class="@imageClassList"> 58 <a onmouseover="swift.Image.swapImage(event)" onmouseout="swift.Image.swapImage(event)" href="@productLink" onclick="@clickProductLink"> 59 @RenderPartial("_partials/image.cshtml", Model.DefaultImage.GetFileViewModel() ?? new Dynamicweb.Frontend.FileViewModel(), parms) 60 </a> 61 </figure> 62 63 <div class="@contentClassList"> 64 <p class="fw-bold mb-1">@Model.Number</p> 65 <div class="d-flex justify-content-between"> 66 <p class="card-text text-truncate mb-1 w-50">@Model.Name</p> 67 68 @if (colorOptions != null) 69 { 70 <ul class="color-list-group"> 71 @foreach (VariantOptionViewModel color in colorOptions) 72 { 73 <li style="background-color: black;" title="@color.Name"><span class="visually-hidden">@color.Name</span></li> 74 } 75 </ul> 76 } 77 </div> 78 <p class="small text-muted"> 79 @Translate("Productlist - Sizes - Text", "Str.:") 80 @if (string.IsNullOrEmpty(Model.VariantId) || Model.VariantId == Model.DefaultVariantId) 81 { 82 <span>@sizeOptions.First().Name - @sizeOptions.Last().Name</span> 83 } 84 else 85 { 86 VariantOptionViewModel sizeVariantOption = sizeOptions.FirstOrDefault(so => Model.VariantId.Contains(so.Id)) ; 87 if (sizeVariantOption != null) 88 { 89 <span>@sizeVariantOption.Name</span> 90 } 91 92 } 93 </p> 94 95 96 97 </div> 98 99100 <div class="@actionClassList">101 @if (!anonymousUser){102 @Model.RenderedHtml.Stock103 }104 <div class="row align-items-center justify-content-end mb-1">105 <span class="fs-6">106 @if (anonymousUser)107 {108 <span class="text-muted fs-8">@Translate("RRP")</span>109 }110 @Model.RenderedHtml.Price111 </span>112 </div>113 </div>114115 @if (Model.Layout == Custom.Constants.ProductListViewModes.ListLayout)116 {117 @:</div>118 }119 </div>120121 <script>122 function clickProductLink(productId, productName, productVariant, productCurrency, productPrice, groupId, groupName) {123 if (typeof gtag !== "undefined") {124 gtag("event", "select_item", {125 item_list_id: groupId ? groupId : "product_list_item_repeater",126 item_list_name: groupName ? groupName : "Product list (Item Repeater)",127 items: [128 {129 item_id: productId,130 item_name: productName,131 currency: productCurrency,132 item_list_id: groupId ? groupId : "product_list_item_repeater",133 item_list_name: groupName ? groupName : "Product list (Item Repeater)",134 item_variant: productVariant,135 price: productPrice136 }137 ]138 });139 }140 }141 </script>142
36 ud af 63 produkter