Error executing template "Designs/Swift/Navigation/Custom_BreadcrumbNavigation.cshtml"
System.InvalidOperationException: Sequence contains no elements
   at System.Linq.Enumerable.First[TSource](IEnumerable`1 source)
   at CompiledRazorTemplates.Dynamic.RazorEngine_4a1b820213984f8cb356e5221ba5fe93.Execute() in D:\dynamicweb.net\Solutions\Novicell\danitech.cloud.dynamicweb-cms.com\Files\Templates\Designs\Swift\Navigation\Custom_BreadcrumbNavigation.cshtml:line 20
   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 Dynamicweb.Ecommerce.ProductCatalog 2 @using Dynamicweb.Frontend 3 @using Dynamicweb.Frontend.Navigation 4 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.Navigation.NavigationTreeViewModel> 5 @{ 6 var nodes = Model.Nodes; 7 var isProduct = false; 8 var productName = string.Empty; 9 10 IList<string> productGroupPathIdList = null; 11 12 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails") && Dynamicweb.Context.Current.Items["ProductDetails"] is ProductViewModel product) 13 { 14 var navigationSettings = new NavigationSettings(); 15 navigationSettings.StartLevel = 0; 16 navigationSettings.StopLevel = 100; 17 navigationSettings.RootPageId = Pageview.Area.UrlName.ToLower().Contains("en") ? 1690 : 1376; 18 navigationSettings.ExpandMode = ExpandMode.All; 19 20 var productGroupPath = product.GroupPaths.First(); 21 if (productGroupPath != null) 22 { 23 productGroupPathIdList = productGroupPath.Select(c => c.Id).ToList(); 24 nodes = Navigation.GetNavigationViewModel(navigationSettings).Nodes; 25 26 isProduct = true; 27 productName = product.Name; 28 } 29 } 30 } 31 32 @if (!Pageview.IsVisualEditorMode) 33 { 34 string menuId = Model.Parameters.ContainsKey("menu-id") ? $"menu_{Model.Parameters["menu-id"].ToString().ToLower()}" : string.Empty; 35 <nav> 36 <ol class="breadcrumb small mb-0 @menuId"> 37 @if (isProduct) 38 { 39 var firstNode = Model.Nodes.FirstOrDefault(); 40 if (firstNode != null) 41 { 42 <li class="breadcrumb-item"> 43 <a href="@firstNode.Link">@firstNode.Name</a> 44 </li> 45 } 46 47 @RenderNodesByProduct(nodes, productGroupPathIdList) 48 49 <li class="breadcrumb-item active"> 50 @productName 51 </li> 52 } 53 else 54 { 55 @RenderNodes(nodes) 56 } 57 </ol> 58 </nav> 59 } 60 else if (Model.Nodes.Count() == 0) 61 { 62 <div class="alert alert-dark m-0" role="alert"> 63 <span>@Translate("Breadcrumb navigation: The navigation will be shown here, if any")</span> 64 </div> 65 } 66 67 @helper RenderNodes(IEnumerable<Dynamicweb.Frontend.Navigation.NavigationTreeNodeViewModel> nodes) 68 { 69 foreach (var node in nodes) 70 { 71 if (node.ShowInBreadcrumb) 72 { 73 if (!string.IsNullOrEmpty(node.Link)) 74 { 75 <li class="breadcrumb-item"> 76 <a href="@node.Link"> 77 @node.Name 78 </a> 79 </li> 80 } 81 else 82 { 83 <li class="breadcrumb-item"> 84 @node.Name 85 </li> 86 } 87 @RenderNodes(node.Nodes) 88 } 89 } 90 } 91 @helper RenderNodesByProduct(IEnumerable<NavigationTreeNodeViewModel> nodes, IList<string> productGroupPathIdList) 92 { 93 foreach (var node in nodes) 94 { 95 if (productGroupPathIdList.Contains(node.GroupId)) 96 { 97 <li class="breadcrumb-item"> 98 <a href="@node.Link">@node.Name</a> 99 </li> 100 101 @RenderNodesByProduct(node.Nodes, productGroupPathIdList) 102 } 103 } 104 } 105

Metrisk Indstik 45° Hun - AISI 316L

Produkt nr Lagerstand Antal Pris Vis mere
Ved at klikke 'Acceptér Alle' så giver til tiladelse til at vi må indsamle information om dig til forskellige formål, hvilket inkluderer: Funktionalitet, Statestik og Marketing