Fav mærker

ALLE DANMARKS FAVORITMÆRKER

Levering

GRATIS LEVERING OG RETURNERING*

100 dage

100 DAGES RETURRET

Error executing template "Designs/Swift-v2/Paragraph/Swift-v2_BackInStockNotification.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_432bcd25c271441baa7310926b12c41a.ExecuteAsync()
   at RazorEngine.Templating.TemplateBase.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineCore.RunTemplate(ICompiledTemplate template, TextWriter writer, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.DynamicWrapperService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass23_0.<Run>b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, Type modelType, Object model, DynamicViewBag viewBag)
   at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template) in /_/src/Application/Providers/Dynamicweb.Rendering.Providers.NetCore/Razor/RazorTemplateRenderingProvider.cs:line 99
   at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template) in E:\A10\_w\2\s\src\Core\Dynamicweb.Core\Rendering\TemplateRenderingService.cs:line 21
   at Dynamicweb.Rendering.Template.RenderRazorTemplate() in E:\A10\_w\2\s\src\Core\Dynamicweb.Core\Rendering\Template.cs:line 749

1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using System.Linq 3 @using Dynamicweb.Ecommerce 4 @using Dynamicweb.Ecommerce.ProductCatalog 5 @using Dynamicweb.Ecommerce.Products 6 @using Dynamicweb.Ecommerce.Stocks 7 8 @functions 9 { 10 private static bool BackInStockRegisteredForUser(ProductViewModel product, string unitId = "", long stocklocationId = 0) 11 { 12 if (!Dynamicweb.Security.UserManagement.User.IsExtranetUserLoggedIn()) return false; 13 14 Product productObject = Services.Products.GetProductById(product.Id, product.VariantId, product.LanguageId); 15 StockLocation stockLocation = Services.StockService.GetStockLocation(stocklocationId); 16 double unitStock = productObject.GetUnitStock(stockLocation, unitId); 17 return unitStock <= 0d && ProductBackInStockNotification.BackInStockNotificationExists(productObject, unitId); 18 } 19 } 20 21 @{ 22 ProductViewModel product = null; 23 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 24 { 25 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 26 } 27 else if (Pageview.Page.Item["DummyProduct"] != null) 28 { 29 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 30 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 31 32 if (productList?.Products is object) 33 { 34 product = productList.Products[0]; 35 } 36 } 37 } 38 39 @if ((product is object && product.ProductType == Dynamicweb.Ecommerce.Products.ProductType.Stock)) 40 { 41 bool productInStock = product.StockLevel > 0 || product.NeverOutOfstock; 42 43 if (!productInStock) 44 { 45 string notifiedMessage = Model.Item.GetString("NotifiedMessage"); 46 string notifiedMessageId = $"NotifiedMessage_item_{Model.Item.SystemName.ToLower()}_{product.Id}_{product.VariantId.Replace(".", "_")}"; 47 48 string horizontalAlign = Model.Item.GetRawValueString("HorizontalAlignment", ""); 49 horizontalAlign = horizontalAlign == "center" ? "justify-content-center" : horizontalAlign; 50 horizontalAlign = horizontalAlign == "end" ? "justify-content-end" : horizontalAlign; 51 horizontalAlign = horizontalAlign == "full" ? "" : horizontalAlign; 52 53 string flexFill = Model.Item.GetRawValueString("HorizontalAlignment", "") == "full" ? "flex-fill" : ""; 54 string fullWidth = Model.Item.GetRawValueString("HorizontalAlignment", "") == "full" ? "w-100" : ""; 55 56 bool notificationRegisteredForUser = BackInStockRegisteredForUser(product); 57 58 <div class="d-flex flex-row w-100 @horizontalAlign @fullWidth item_@Model.Item.SystemName.ToLower()"> 59 <div class="@horizontalAlign @fullWidth @(notificationRegisteredForUser ? "" : "d-none")" id="@notifiedMessageId"> 60 @notifiedMessage 61 </div> 62 63 @if (!notificationRegisteredForUser) 64 { 65 66 string notifyIcon = Model.Item.GetString("Icon"); 67 string notifyLabel = !notifyIcon.Contains("_none") ? "<span class=\"icon-2\">" + ReadFile(notifyIcon) + "</span>" : ""; 68 notifyLabel += " " + Translate("Notify me when available"); 69 70 string modalId = $"modal_item_{Model.Item.SystemName.ToLower()}_{product.Id}_{product.VariantId.Replace(".", "_")}"; 71 string formId = $"NotificationForm_item_{Model.Item.SystemName.ToLower()}_{product.Id}_{product.VariantId.Replace(".", "_")}"; 72 string notificationButtonId = $"NotificationButton_item_{Model.Item.SystemName.ToLower()}_{product.Id}_{product.VariantId.Replace(".", "_")}"; 73 string notificationOnClick = !Pageview.IsVisualEditorMode ? $"swift.BackInStockNotification.SubmitNotification('{formId}', '{modalId}', '{notifiedMessageId}', '{notificationButtonId}')" : ""; 74 75 string productPage = $"Default.aspx?ID={GetPageIdByNavigationTag("ProductDetailPage")}"; 76 77 <div class="d-flex @horizontalAlign @fullWidth js-input-group"> 78 <div class="input-group input-primary-button-group flex-nowrap"> 79 <button type="button" class="btn btn-primary @flexFill" data-dw-button="primary" id="@notificationButtonId" data-bs-toggle="modal" data-bs-target="#@modalId"> 80 <span class="text-nowrap d-flex align-items-center justify-content-center gap-2"> 81 @notifyLabel 82 </span> 83 </button> 84 </div> 85 </div> 86 87 <div class="modal fade" id="@modalId" tabindex="-1" aria-labelledby="label_@modalId" aria-hidden="true"> 88 <div class="modal-dialog pt-8"> 89 <div class="modal-content"> 90 <div class="modal-header"> 91 <h5 class="modal-title" id="label_@modalId">@Translate("Back in stock")</h5> 92 <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="@Translate("Close")"></button> 93 </div> 94 <div class="modal-body"> 95 <form name="@product.Id" id="@formId" method="post" action="@productPage"> 96 <input type="hidden" name="ProductID" value="@product.Id" /> 97 <input type="hidden" name="VariantID" value="@product.VariantId" /> 98 <input type="hidden" name="LanguageID" value="@product.LanguageId" /> 99 <input type="hidden" name="CartCmd" value="createnotificationforthisproduct" /> 100 <div class="m-2"> 101 @Translate("Send me an email when the product is in stock.") 102 </div> 103 <div class="form-floating m-2"> 104 <input class="form-control" type="text" id="NotificationEmail" value="@(Pageview.User != null ? Pageview.User.Email : "")" name="NotificationEmail" placeholder="@Translate("Email")" required="required" aria-required="aria-required" /> 105 <label for="NotificationEmail" class="form-label">@Translate("Email")</label> 106 </div> 107 </form> 108 </div> 109 <div class="modal-footer"> 110 <button type="button" class="btn btn-primary" data-dw-button="primary" onclick="@notificationOnClick">@Translate("Submit")</button> 111 </div> 112 </div> 113 </div> 114 </div> 115 } 116 </div> 117 } 118 } 119 else if (Pageview.IsVisualEditorMode) 120 { 121 <div class="alert alert-dark m-0">@Translate("Back in stock notification will be shown here")</div> 122 } 123
Error executing template "Designs/Swift-v2/Paragraph/Swift-v2_ProductCatalogDetailsApp.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_4221672b82f444bc8196148607b81036.ExecuteAsync()
   at RazorEngine.Templating.TemplateBase.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineCore.RunTemplate(ICompiledTemplate template, TextWriter writer, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.DynamicWrapperService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass23_0.<Run>b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, Type modelType, Object model, DynamicViewBag viewBag)
   at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template) in /_/src/Application/Providers/Dynamicweb.Rendering.Providers.NetCore/Razor/RazorTemplateRenderingProvider.cs:line 99
   at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template) in E:\A10\_w\2\s\src\Core\Dynamicweb.Core\Rendering\TemplateRenderingService.cs:line 21
   at Dynamicweb.Rendering.Template.RenderRazorTemplate() in E:\A10\_w\2\s\src\Core\Dynamicweb.Core\Rendering\Template.cs:line 749

1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using Dynamicweb.Ecommerce.ProductCatalog 3 4 @{ 5 //Set default product data for use in Visual Editor 6 if (Pageview.IsVisualEditorMode) 7 { 8 ProductViewModelSettings productSetting = new ProductViewModelSettings 9 { 10 LanguageId = Dynamicweb.Ecommerce.Common.Context.LanguageID, 11 CurrencyCode = Dynamicweb.Ecommerce.Common.Context.Currency.Code, 12 CountryCode = Dynamicweb.Ecommerce.Common.Context.Country.Code2, 13 ShopId = Pageview.Area.EcomShopId 14 }; 15 16 string selectedDummyProduct = "PROD1"; 17 var list = new ProductListViewModel(); 18 if (Model.Item.GetValue("DummyProduct") != null) 19 { 20 list = Model.Item.GetValue("DummyProduct") as ProductListViewModel; 21 22 foreach (var product in list.Products) 23 { 24 selectedDummyProduct = product.Id; 25 } 26 27 ProductViewModel dummyProduct = ViewModelFactory.CreateView(productSetting, selectedDummyProduct); 28 29 if (!Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 30 { 31 Dynamicweb.Context.Current.Items.Add("ProductDetails", dummyProduct); 32 } 33 } 34 else 35 { 36 <div class="alert alert-danger" role="alert"> 37 <span>@Translate("Please select a Dummy product on this paragraph")</span> 38 </div> 39 } 40 } 41 else if (!Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 42 { 43 ProductViewModel dummyProduct = new ProductViewModel(); 44 Dynamicweb.Context.Current.Items.Add("ProductDetails", dummyProduct); 45 } 46 } 47 48 @if (Pageview.IsVisualEditorMode) 49 { 50 <div class="alert alert-info" role="alert"> 51 <span>@Translate("Product catalog App: Edit this column to configure. (Product catalog app must be attached this paragraph)")</span> 52 </div> 53 } 54 55 <div class="item_@Model.Item.SystemName.ToLower()"> 56 @Model.GetModuleOutput() 57 </div> 58
Error executing template "Designs/Swift-v2/Paragraph/Swift-v2_BackInStockNotification.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_432bcd25c271441baa7310926b12c41a.ExecuteAsync()
   at RazorEngine.Templating.TemplateBase.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineCore.RunTemplate(ICompiledTemplate template, TextWriter writer, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.DynamicWrapperService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass23_0.<Run>b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, Type modelType, Object model, DynamicViewBag viewBag)
   at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template) in /_/src/Application/Providers/Dynamicweb.Rendering.Providers.NetCore/Razor/RazorTemplateRenderingProvider.cs:line 99
   at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template) in E:\A10\_w\2\s\src\Core\Dynamicweb.Core\Rendering\TemplateRenderingService.cs:line 21
   at Dynamicweb.Rendering.Template.RenderRazorTemplate() in E:\A10\_w\2\s\src\Core\Dynamicweb.Core\Rendering\Template.cs:line 749

1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using System.Linq 3 @using Dynamicweb.Ecommerce 4 @using Dynamicweb.Ecommerce.ProductCatalog 5 @using Dynamicweb.Ecommerce.Products 6 @using Dynamicweb.Ecommerce.Stocks 7 8 @functions 9 { 10 private static bool BackInStockRegisteredForUser(ProductViewModel product, string unitId = "", long stocklocationId = 0) 11 { 12 if (!Dynamicweb.Security.UserManagement.User.IsExtranetUserLoggedIn()) return false; 13 14 Product productObject = Services.Products.GetProductById(product.Id, product.VariantId, product.LanguageId); 15 StockLocation stockLocation = Services.StockService.GetStockLocation(stocklocationId); 16 double unitStock = productObject.GetUnitStock(stockLocation, unitId); 17 return unitStock <= 0d && ProductBackInStockNotification.BackInStockNotificationExists(productObject, unitId); 18 } 19 } 20 21 @{ 22 ProductViewModel product = null; 23 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 24 { 25 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 26 } 27 else if (Pageview.Page.Item["DummyProduct"] != null) 28 { 29 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 30 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 31 32 if (productList?.Products is object) 33 { 34 product = productList.Products[0]; 35 } 36 } 37 } 38 39 @if ((product is object && product.ProductType == Dynamicweb.Ecommerce.Products.ProductType.Stock)) 40 { 41 bool productInStock = product.StockLevel > 0 || product.NeverOutOfstock; 42 43 if (!productInStock) 44 { 45 string notifiedMessage = Model.Item.GetString("NotifiedMessage"); 46 string notifiedMessageId = $"NotifiedMessage_item_{Model.Item.SystemName.ToLower()}_{product.Id}_{product.VariantId.Replace(".", "_")}"; 47 48 string horizontalAlign = Model.Item.GetRawValueString("HorizontalAlignment", ""); 49 horizontalAlign = horizontalAlign == "center" ? "justify-content-center" : horizontalAlign; 50 horizontalAlign = horizontalAlign == "end" ? "justify-content-end" : horizontalAlign; 51 horizontalAlign = horizontalAlign == "full" ? "" : horizontalAlign; 52 53 string flexFill = Model.Item.GetRawValueString("HorizontalAlignment", "") == "full" ? "flex-fill" : ""; 54 string fullWidth = Model.Item.GetRawValueString("HorizontalAlignment", "") == "full" ? "w-100" : ""; 55 56 bool notificationRegisteredForUser = BackInStockRegisteredForUser(product); 57 58 <div class="d-flex flex-row w-100 @horizontalAlign @fullWidth item_@Model.Item.SystemName.ToLower()"> 59 <div class="@horizontalAlign @fullWidth @(notificationRegisteredForUser ? "" : "d-none")" id="@notifiedMessageId"> 60 @notifiedMessage 61 </div> 62 63 @if (!notificationRegisteredForUser) 64 { 65 66 string notifyIcon = Model.Item.GetString("Icon"); 67 string notifyLabel = !notifyIcon.Contains("_none") ? "<span class=\"icon-2\">" + ReadFile(notifyIcon) + "</span>" : ""; 68 notifyLabel += " " + Translate("Notify me when available"); 69 70 string modalId = $"modal_item_{Model.Item.SystemName.ToLower()}_{product.Id}_{product.VariantId.Replace(".", "_")}"; 71 string formId = $"NotificationForm_item_{Model.Item.SystemName.ToLower()}_{product.Id}_{product.VariantId.Replace(".", "_")}"; 72 string notificationButtonId = $"NotificationButton_item_{Model.Item.SystemName.ToLower()}_{product.Id}_{product.VariantId.Replace(".", "_")}"; 73 string notificationOnClick = !Pageview.IsVisualEditorMode ? $"swift.BackInStockNotification.SubmitNotification('{formId}', '{modalId}', '{notifiedMessageId}', '{notificationButtonId}')" : ""; 74 75 string productPage = $"Default.aspx?ID={GetPageIdByNavigationTag("ProductDetailPage")}"; 76 77 <div class="d-flex @horizontalAlign @fullWidth js-input-group"> 78 <div class="input-group input-primary-button-group flex-nowrap"> 79 <button type="button" class="btn btn-primary @flexFill" data-dw-button="primary" id="@notificationButtonId" data-bs-toggle="modal" data-bs-target="#@modalId"> 80 <span class="text-nowrap d-flex align-items-center justify-content-center gap-2"> 81 @notifyLabel 82 </span> 83 </button> 84 </div> 85 </div> 86 87 <div class="modal fade" id="@modalId" tabindex="-1" aria-labelledby="label_@modalId" aria-hidden="true"> 88 <div class="modal-dialog pt-8"> 89 <div class="modal-content"> 90 <div class="modal-header"> 91 <h5 class="modal-title" id="label_@modalId">@Translate("Back in stock")</h5> 92 <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="@Translate("Close")"></button> 93 </div> 94 <div class="modal-body"> 95 <form name="@product.Id" id="@formId" method="post" action="@productPage"> 96 <input type="hidden" name="ProductID" value="@product.Id" /> 97 <input type="hidden" name="VariantID" value="@product.VariantId" /> 98 <input type="hidden" name="LanguageID" value="@product.LanguageId" /> 99 <input type="hidden" name="CartCmd" value="createnotificationforthisproduct" /> 100 <div class="m-2"> 101 @Translate("Send me an email when the product is in stock.") 102 </div> 103 <div class="form-floating m-2"> 104 <input class="form-control" type="text" id="NotificationEmail" value="@(Pageview.User != null ? Pageview.User.Email : "")" name="NotificationEmail" placeholder="@Translate("Email")" required="required" aria-required="aria-required" /> 105 <label for="NotificationEmail" class="form-label">@Translate("Email")</label> 106 </div> 107 </form> 108 </div> 109 <div class="modal-footer"> 110 <button type="button" class="btn btn-primary" data-dw-button="primary" onclick="@notificationOnClick">@Translate("Submit")</button> 111 </div> 112 </div> 113 </div> 114 </div> 115 } 116 </div> 117 } 118 } 119 else if (Pageview.IsVisualEditorMode) 120 { 121 <div class="alert alert-dark m-0">@Translate("Back in stock notification will be shown here")</div> 122 } 123
Error executing template "Designs/Swift-v2/Paragraph/Swift-v2_BackInStockNotification.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_432bcd25c271441baa7310926b12c41a.ExecuteAsync()
   at RazorEngine.Templating.TemplateBase.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineCore.RunTemplate(ICompiledTemplate template, TextWriter writer, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.DynamicWrapperService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass23_0.<Run>b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, Type modelType, Object model, DynamicViewBag viewBag)
   at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template) in /_/src/Application/Providers/Dynamicweb.Rendering.Providers.NetCore/Razor/RazorTemplateRenderingProvider.cs:line 99
   at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template) in E:\A10\_w\2\s\src\Core\Dynamicweb.Core\Rendering\TemplateRenderingService.cs:line 21
   at Dynamicweb.Rendering.Template.RenderRazorTemplate() in E:\A10\_w\2\s\src\Core\Dynamicweb.Core\Rendering\Template.cs:line 749

1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using System.Linq 3 @using Dynamicweb.Ecommerce 4 @using Dynamicweb.Ecommerce.ProductCatalog 5 @using Dynamicweb.Ecommerce.Products 6 @using Dynamicweb.Ecommerce.Stocks 7 8 @functions 9 { 10 private static bool BackInStockRegisteredForUser(ProductViewModel product, string unitId = "", long stocklocationId = 0) 11 { 12 if (!Dynamicweb.Security.UserManagement.User.IsExtranetUserLoggedIn()) return false; 13 14 Product productObject = Services.Products.GetProductById(product.Id, product.VariantId, product.LanguageId); 15 StockLocation stockLocation = Services.StockService.GetStockLocation(stocklocationId); 16 double unitStock = productObject.GetUnitStock(stockLocation, unitId); 17 return unitStock <= 0d && ProductBackInStockNotification.BackInStockNotificationExists(productObject, unitId); 18 } 19 } 20 21 @{ 22 ProductViewModel product = null; 23 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 24 { 25 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 26 } 27 else if (Pageview.Page.Item["DummyProduct"] != null) 28 { 29 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 30 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 31 32 if (productList?.Products is object) 33 { 34 product = productList.Products[0]; 35 } 36 } 37 } 38 39 @if ((product is object && product.ProductType == Dynamicweb.Ecommerce.Products.ProductType.Stock)) 40 { 41 bool productInStock = product.StockLevel > 0 || product.NeverOutOfstock; 42 43 if (!productInStock) 44 { 45 string notifiedMessage = Model.Item.GetString("NotifiedMessage"); 46 string notifiedMessageId = $"NotifiedMessage_item_{Model.Item.SystemName.ToLower()}_{product.Id}_{product.VariantId.Replace(".", "_")}"; 47 48 string horizontalAlign = Model.Item.GetRawValueString("HorizontalAlignment", ""); 49 horizontalAlign = horizontalAlign == "center" ? "justify-content-center" : horizontalAlign; 50 horizontalAlign = horizontalAlign == "end" ? "justify-content-end" : horizontalAlign; 51 horizontalAlign = horizontalAlign == "full" ? "" : horizontalAlign; 52 53 string flexFill = Model.Item.GetRawValueString("HorizontalAlignment", "") == "full" ? "flex-fill" : ""; 54 string fullWidth = Model.Item.GetRawValueString("HorizontalAlignment", "") == "full" ? "w-100" : ""; 55 56 bool notificationRegisteredForUser = BackInStockRegisteredForUser(product); 57 58 <div class="d-flex flex-row w-100 @horizontalAlign @fullWidth item_@Model.Item.SystemName.ToLower()"> 59 <div class="@horizontalAlign @fullWidth @(notificationRegisteredForUser ? "" : "d-none")" id="@notifiedMessageId"> 60 @notifiedMessage 61 </div> 62 63 @if (!notificationRegisteredForUser) 64 { 65 66 string notifyIcon = Model.Item.GetString("Icon"); 67 string notifyLabel = !notifyIcon.Contains("_none") ? "<span class=\"icon-2\">" + ReadFile(notifyIcon) + "</span>" : ""; 68 notifyLabel += " " + Translate("Notify me when available"); 69 70 string modalId = $"modal_item_{Model.Item.SystemName.ToLower()}_{product.Id}_{product.VariantId.Replace(".", "_")}"; 71 string formId = $"NotificationForm_item_{Model.Item.SystemName.ToLower()}_{product.Id}_{product.VariantId.Replace(".", "_")}"; 72 string notificationButtonId = $"NotificationButton_item_{Model.Item.SystemName.ToLower()}_{product.Id}_{product.VariantId.Replace(".", "_")}"; 73 string notificationOnClick = !Pageview.IsVisualEditorMode ? $"swift.BackInStockNotification.SubmitNotification('{formId}', '{modalId}', '{notifiedMessageId}', '{notificationButtonId}')" : ""; 74 75 string productPage = $"Default.aspx?ID={GetPageIdByNavigationTag("ProductDetailPage")}"; 76 77 <div class="d-flex @horizontalAlign @fullWidth js-input-group"> 78 <div class="input-group input-primary-button-group flex-nowrap"> 79 <button type="button" class="btn btn-primary @flexFill" data-dw-button="primary" id="@notificationButtonId" data-bs-toggle="modal" data-bs-target="#@modalId"> 80 <span class="text-nowrap d-flex align-items-center justify-content-center gap-2"> 81 @notifyLabel 82 </span> 83 </button> 84 </div> 85 </div> 86 87 <div class="modal fade" id="@modalId" tabindex="-1" aria-labelledby="label_@modalId" aria-hidden="true"> 88 <div class="modal-dialog pt-8"> 89 <div class="modal-content"> 90 <div class="modal-header"> 91 <h5 class="modal-title" id="label_@modalId">@Translate("Back in stock")</h5> 92 <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="@Translate("Close")"></button> 93 </div> 94 <div class="modal-body"> 95 <form name="@product.Id" id="@formId" method="post" action="@productPage"> 96 <input type="hidden" name="ProductID" value="@product.Id" /> 97 <input type="hidden" name="VariantID" value="@product.VariantId" /> 98 <input type="hidden" name="LanguageID" value="@product.LanguageId" /> 99 <input type="hidden" name="CartCmd" value="createnotificationforthisproduct" /> 100 <div class="m-2"> 101 @Translate("Send me an email when the product is in stock.") 102 </div> 103 <div class="form-floating m-2"> 104 <input class="form-control" type="text" id="NotificationEmail" value="@(Pageview.User != null ? Pageview.User.Email : "")" name="NotificationEmail" placeholder="@Translate("Email")" required="required" aria-required="aria-required" /> 105 <label for="NotificationEmail" class="form-label">@Translate("Email")</label> 106 </div> 107 </form> 108 </div> 109 <div class="modal-footer"> 110 <button type="button" class="btn btn-primary" data-dw-button="primary" onclick="@notificationOnClick">@Translate("Submit")</button> 111 </div> 112 </div> 113 </div> 114 </div> 115 } 116 </div> 117 } 118 } 119 else if (Pageview.IsVisualEditorMode) 120 { 121 <div class="alert alert-dark m-0">@Translate("Back in stock notification will be shown here")</div> 122 } 123
Error executing template "Designs/Swift-v2/Paragraph/Swift-v2_BackInStockNotification.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_432bcd25c271441baa7310926b12c41a.ExecuteAsync()
   at RazorEngine.Templating.TemplateBase.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineCore.RunTemplate(ICompiledTemplate template, TextWriter writer, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.DynamicWrapperService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass23_0.<Run>b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, Type modelType, Object model, DynamicViewBag viewBag)
   at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template) in /_/src/Application/Providers/Dynamicweb.Rendering.Providers.NetCore/Razor/RazorTemplateRenderingProvider.cs:line 99
   at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template) in E:\A10\_w\2\s\src\Core\Dynamicweb.Core\Rendering\TemplateRenderingService.cs:line 21
   at Dynamicweb.Rendering.Template.RenderRazorTemplate() in E:\A10\_w\2\s\src\Core\Dynamicweb.Core\Rendering\Template.cs:line 749

1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using System.Linq 3 @using Dynamicweb.Ecommerce 4 @using Dynamicweb.Ecommerce.ProductCatalog 5 @using Dynamicweb.Ecommerce.Products 6 @using Dynamicweb.Ecommerce.Stocks 7 8 @functions 9 { 10 private static bool BackInStockRegisteredForUser(ProductViewModel product, string unitId = "", long stocklocationId = 0) 11 { 12 if (!Dynamicweb.Security.UserManagement.User.IsExtranetUserLoggedIn()) return false; 13 14 Product productObject = Services.Products.GetProductById(product.Id, product.VariantId, product.LanguageId); 15 StockLocation stockLocation = Services.StockService.GetStockLocation(stocklocationId); 16 double unitStock = productObject.GetUnitStock(stockLocation, unitId); 17 return unitStock <= 0d && ProductBackInStockNotification.BackInStockNotificationExists(productObject, unitId); 18 } 19 } 20 21 @{ 22 ProductViewModel product = null; 23 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 24 { 25 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 26 } 27 else if (Pageview.Page.Item["DummyProduct"] != null) 28 { 29 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 30 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 31 32 if (productList?.Products is object) 33 { 34 product = productList.Products[0]; 35 } 36 } 37 } 38 39 @if ((product is object && product.ProductType == Dynamicweb.Ecommerce.Products.ProductType.Stock)) 40 { 41 bool productInStock = product.StockLevel > 0 || product.NeverOutOfstock; 42 43 if (!productInStock) 44 { 45 string notifiedMessage = Model.Item.GetString("NotifiedMessage"); 46 string notifiedMessageId = $"NotifiedMessage_item_{Model.Item.SystemName.ToLower()}_{product.Id}_{product.VariantId.Replace(".", "_")}"; 47 48 string horizontalAlign = Model.Item.GetRawValueString("HorizontalAlignment", ""); 49 horizontalAlign = horizontalAlign == "center" ? "justify-content-center" : horizontalAlign; 50 horizontalAlign = horizontalAlign == "end" ? "justify-content-end" : horizontalAlign; 51 horizontalAlign = horizontalAlign == "full" ? "" : horizontalAlign; 52 53 string flexFill = Model.Item.GetRawValueString("HorizontalAlignment", "") == "full" ? "flex-fill" : ""; 54 string fullWidth = Model.Item.GetRawValueString("HorizontalAlignment", "") == "full" ? "w-100" : ""; 55 56 bool notificationRegisteredForUser = BackInStockRegisteredForUser(product); 57 58 <div class="d-flex flex-row w-100 @horizontalAlign @fullWidth item_@Model.Item.SystemName.ToLower()"> 59 <div class="@horizontalAlign @fullWidth @(notificationRegisteredForUser ? "" : "d-none")" id="@notifiedMessageId"> 60 @notifiedMessage 61 </div> 62 63 @if (!notificationRegisteredForUser) 64 { 65 66 string notifyIcon = Model.Item.GetString("Icon"); 67 string notifyLabel = !notifyIcon.Contains("_none") ? "<span class=\"icon-2\">" + ReadFile(notifyIcon) + "</span>" : ""; 68 notifyLabel += " " + Translate("Notify me when available"); 69 70 string modalId = $"modal_item_{Model.Item.SystemName.ToLower()}_{product.Id}_{product.VariantId.Replace(".", "_")}"; 71 string formId = $"NotificationForm_item_{Model.Item.SystemName.ToLower()}_{product.Id}_{product.VariantId.Replace(".", "_")}"; 72 string notificationButtonId = $"NotificationButton_item_{Model.Item.SystemName.ToLower()}_{product.Id}_{product.VariantId.Replace(".", "_")}"; 73 string notificationOnClick = !Pageview.IsVisualEditorMode ? $"swift.BackInStockNotification.SubmitNotification('{formId}', '{modalId}', '{notifiedMessageId}', '{notificationButtonId}')" : ""; 74 75 string productPage = $"Default.aspx?ID={GetPageIdByNavigationTag("ProductDetailPage")}"; 76 77 <div class="d-flex @horizontalAlign @fullWidth js-input-group"> 78 <div class="input-group input-primary-button-group flex-nowrap"> 79 <button type="button" class="btn btn-primary @flexFill" data-dw-button="primary" id="@notificationButtonId" data-bs-toggle="modal" data-bs-target="#@modalId"> 80 <span class="text-nowrap d-flex align-items-center justify-content-center gap-2"> 81 @notifyLabel 82 </span> 83 </button> 84 </div> 85 </div> 86 87 <div class="modal fade" id="@modalId" tabindex="-1" aria-labelledby="label_@modalId" aria-hidden="true"> 88 <div class="modal-dialog pt-8"> 89 <div class="modal-content"> 90 <div class="modal-header"> 91 <h5 class="modal-title" id="label_@modalId">@Translate("Back in stock")</h5> 92 <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="@Translate("Close")"></button> 93 </div> 94 <div class="modal-body"> 95 <form name="@product.Id" id="@formId" method="post" action="@productPage"> 96 <input type="hidden" name="ProductID" value="@product.Id" /> 97 <input type="hidden" name="VariantID" value="@product.VariantId" /> 98 <input type="hidden" name="LanguageID" value="@product.LanguageId" /> 99 <input type="hidden" name="CartCmd" value="createnotificationforthisproduct" /> 100 <div class="m-2"> 101 @Translate("Send me an email when the product is in stock.") 102 </div> 103 <div class="form-floating m-2"> 104 <input class="form-control" type="text" id="NotificationEmail" value="@(Pageview.User != null ? Pageview.User.Email : "")" name="NotificationEmail" placeholder="@Translate("Email")" required="required" aria-required="aria-required" /> 105 <label for="NotificationEmail" class="form-label">@Translate("Email")</label> 106 </div> 107 </form> 108 </div> 109 <div class="modal-footer"> 110 <button type="button" class="btn btn-primary" data-dw-button="primary" onclick="@notificationOnClick">@Translate("Submit")</button> 111 </div> 112 </div> 113 </div> 114 </div> 115 } 116 </div> 117 } 118 } 119 else if (Pageview.IsVisualEditorMode) 120 { 121 <div class="alert alert-dark m-0">@Translate("Back in stock notification will be shown here")</div> 122 } 123
Error executing template "Designs/Swift-v2/Paragraph/Swift-v2_BackInStockNotification.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_432bcd25c271441baa7310926b12c41a.ExecuteAsync()
   at RazorEngine.Templating.TemplateBase.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineCore.RunTemplate(ICompiledTemplate template, TextWriter writer, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.DynamicWrapperService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass23_0.<Run>b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, Type modelType, Object model, DynamicViewBag viewBag)
   at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template) in /_/src/Application/Providers/Dynamicweb.Rendering.Providers.NetCore/Razor/RazorTemplateRenderingProvider.cs:line 99
   at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template) in E:\A10\_w\2\s\src\Core\Dynamicweb.Core\Rendering\TemplateRenderingService.cs:line 21
   at Dynamicweb.Rendering.Template.RenderRazorTemplate() in E:\A10\_w\2\s\src\Core\Dynamicweb.Core\Rendering\Template.cs:line 749

1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using System.Linq 3 @using Dynamicweb.Ecommerce 4 @using Dynamicweb.Ecommerce.ProductCatalog 5 @using Dynamicweb.Ecommerce.Products 6 @using Dynamicweb.Ecommerce.Stocks 7 8 @functions 9 { 10 private static bool BackInStockRegisteredForUser(ProductViewModel product, string unitId = "", long stocklocationId = 0) 11 { 12 if (!Dynamicweb.Security.UserManagement.User.IsExtranetUserLoggedIn()) return false; 13 14 Product productObject = Services.Products.GetProductById(product.Id, product.VariantId, product.LanguageId); 15 StockLocation stockLocation = Services.StockService.GetStockLocation(stocklocationId); 16 double unitStock = productObject.GetUnitStock(stockLocation, unitId); 17 return unitStock <= 0d && ProductBackInStockNotification.BackInStockNotificationExists(productObject, unitId); 18 } 19 } 20 21 @{ 22 ProductViewModel product = null; 23 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 24 { 25 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 26 } 27 else if (Pageview.Page.Item["DummyProduct"] != null) 28 { 29 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 30 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 31 32 if (productList?.Products is object) 33 { 34 product = productList.Products[0]; 35 } 36 } 37 } 38 39 @if ((product is object && product.ProductType == Dynamicweb.Ecommerce.Products.ProductType.Stock)) 40 { 41 bool productInStock = product.StockLevel > 0 || product.NeverOutOfstock; 42 43 if (!productInStock) 44 { 45 string notifiedMessage = Model.Item.GetString("NotifiedMessage"); 46 string notifiedMessageId = $"NotifiedMessage_item_{Model.Item.SystemName.ToLower()}_{product.Id}_{product.VariantId.Replace(".", "_")}"; 47 48 string horizontalAlign = Model.Item.GetRawValueString("HorizontalAlignment", ""); 49 horizontalAlign = horizontalAlign == "center" ? "justify-content-center" : horizontalAlign; 50 horizontalAlign = horizontalAlign == "end" ? "justify-content-end" : horizontalAlign; 51 horizontalAlign = horizontalAlign == "full" ? "" : horizontalAlign; 52 53 string flexFill = Model.Item.GetRawValueString("HorizontalAlignment", "") == "full" ? "flex-fill" : ""; 54 string fullWidth = Model.Item.GetRawValueString("HorizontalAlignment", "") == "full" ? "w-100" : ""; 55 56 bool notificationRegisteredForUser = BackInStockRegisteredForUser(product); 57 58 <div class="d-flex flex-row w-100 @horizontalAlign @fullWidth item_@Model.Item.SystemName.ToLower()"> 59 <div class="@horizontalAlign @fullWidth @(notificationRegisteredForUser ? "" : "d-none")" id="@notifiedMessageId"> 60 @notifiedMessage 61 </div> 62 63 @if (!notificationRegisteredForUser) 64 { 65 66 string notifyIcon = Model.Item.GetString("Icon"); 67 string notifyLabel = !notifyIcon.Contains("_none") ? "<span class=\"icon-2\">" + ReadFile(notifyIcon) + "</span>" : ""; 68 notifyLabel += " " + Translate("Notify me when available"); 69 70 string modalId = $"modal_item_{Model.Item.SystemName.ToLower()}_{product.Id}_{product.VariantId.Replace(".", "_")}"; 71 string formId = $"NotificationForm_item_{Model.Item.SystemName.ToLower()}_{product.Id}_{product.VariantId.Replace(".", "_")}"; 72 string notificationButtonId = $"NotificationButton_item_{Model.Item.SystemName.ToLower()}_{product.Id}_{product.VariantId.Replace(".", "_")}"; 73 string notificationOnClick = !Pageview.IsVisualEditorMode ? $"swift.BackInStockNotification.SubmitNotification('{formId}', '{modalId}', '{notifiedMessageId}', '{notificationButtonId}')" : ""; 74 75 string productPage = $"Default.aspx?ID={GetPageIdByNavigationTag("ProductDetailPage")}"; 76 77 <div class="d-flex @horizontalAlign @fullWidth js-input-group"> 78 <div class="input-group input-primary-button-group flex-nowrap"> 79 <button type="button" class="btn btn-primary @flexFill" data-dw-button="primary" id="@notificationButtonId" data-bs-toggle="modal" data-bs-target="#@modalId"> 80 <span class="text-nowrap d-flex align-items-center justify-content-center gap-2"> 81 @notifyLabel 82 </span> 83 </button> 84 </div> 85 </div> 86 87 <div class="modal fade" id="@modalId" tabindex="-1" aria-labelledby="label_@modalId" aria-hidden="true"> 88 <div class="modal-dialog pt-8"> 89 <div class="modal-content"> 90 <div class="modal-header"> 91 <h5 class="modal-title" id="label_@modalId">@Translate("Back in stock")</h5> 92 <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="@Translate("Close")"></button> 93 </div> 94 <div class="modal-body"> 95 <form name="@product.Id" id="@formId" method="post" action="@productPage"> 96 <input type="hidden" name="ProductID" value="@product.Id" /> 97 <input type="hidden" name="VariantID" value="@product.VariantId" /> 98 <input type="hidden" name="LanguageID" value="@product.LanguageId" /> 99 <input type="hidden" name="CartCmd" value="createnotificationforthisproduct" /> 100 <div class="m-2"> 101 @Translate("Send me an email when the product is in stock.") 102 </div> 103 <div class="form-floating m-2"> 104 <input class="form-control" type="text" id="NotificationEmail" value="@(Pageview.User != null ? Pageview.User.Email : "")" name="NotificationEmail" placeholder="@Translate("Email")" required="required" aria-required="aria-required" /> 105 <label for="NotificationEmail" class="form-label">@Translate("Email")</label> 106 </div> 107 </form> 108 </div> 109 <div class="modal-footer"> 110 <button type="button" class="btn btn-primary" data-dw-button="primary" onclick="@notificationOnClick">@Translate("Submit")</button> 111 </div> 112 </div> 113 </div> 114 </div> 115 } 116 </div> 117 } 118 } 119 else if (Pageview.IsVisualEditorMode) 120 { 121 <div class="alert alert-dark m-0">@Translate("Back in stock notification will be shown here")</div> 122 } 123
Error executing template "Designs/Swift-v2/Paragraph/Swift-v2_ProductComponentSlider.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_d11a7bed5bef4a08bd6d9ad1e31a9c2f.ExecuteAsync()
   at RazorEngine.Templating.TemplateBase.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineCore.RunTemplate(ICompiledTemplate template, TextWriter writer, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.DynamicWrapperService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass23_0.<Run>b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, Type modelType, Object model, DynamicViewBag viewBag)
   at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template) in /_/src/Application/Providers/Dynamicweb.Rendering.Providers.NetCore/Razor/RazorTemplateRenderingProvider.cs:line 99
   at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template) in E:\A10\_w\2\s\src\Core\Dynamicweb.Core\Rendering\TemplateRenderingService.cs:line 21
   at Dynamicweb.Rendering.Template.RenderRazorTemplate() in E:\A10\_w\2\s\src\Core\Dynamicweb.Core\Rendering\Template.cs:line 749

1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using Dynamicweb.Core 3 @using Dynamicweb.Ecommerce.ProductCatalog 4 5 @{ 6 AddScript("/Files/Templates/Designs/Swift-v2/Assets/lib/swiffy-slider/dist/js/swiffy-slider.min.js"); 7 AddStylesheet("/Files/Templates/Designs/Swift-v2/Assets/lib/swiffy-slider/dist/css/swiffy-slider.min.css"); 8 9 ProductViewModel product = null; 10 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 11 { 12 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 13 } 14 else if (Pageview.Page.Item["DummyProduct"] != null && Pageview.IsVisualEditorMode) 15 { 16 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 17 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 18 19 if (productList?.Products is object) 20 { 21 product = productList.Products[0]; 22 } 23 } 24 25 string layout = Model.Item.GetRawValueString("Layout") == "slider" ? "ProductSliderComponent" : "ProductGridComponent"; 26 string lazyHeight = Model.Item.GetBoolean("SetMinHeightForLazyLoading") ? "min-height: 360px" : ""; 27 28 //Link generation 29 string pageId = Model.Item.GetLink("ProductSliderServicePage") != null ? Model.Item.GetLink("ProductSliderServicePage").PageId.ToString() : ""; 30 string servicePageByNavigationTag = GetPageIdByNavigationTag("ProductSliderService") != 0 ? GetPageIdByNavigationTag("ProductSliderService").ToString() : ""; 31 pageId = pageId == "" ? servicePageByNavigationTag : pageId; 32 33 string url = "/Default.aspx?ID=" + pageId; 34 35 if (Pageview.IsVisualEditorMode) 36 { 37 url += "&VisualEdit=True"; 38 } 39 40 url += $"&ProductListPartial={layout}"; //Use this to render either a slider or a grid 41 42 //Source type 43 string sourceType = Model.Item.GetRawValueString("RelationType", "trending"); 44 IList<string> relateFromProductIds = new List<string> { }; 45 IList<string> relateFromProductVariantIds = new List<string> { }; 46 IList<string> relateFromGroupIds = new List<string> { }; 47 bool hasVariants = false; 48 ProductListViewModel relateToViewModel = Model.Item.GetValue<ProductListViewModel>("RelateTo"); 49 50 //--- PRODUCTS --- 51 if (sourceType == "variants" || sourceType == "frequently" || sourceType == "selected") 52 { 53 if (relateToViewModel?.Products != null) 54 { 55 hasVariants = relateToViewModel.Products.Any(p => !string.IsNullOrEmpty(p.VariantId)); 56 foreach (var fromProduct in relateToViewModel.Products) 57 { 58 if (hasVariants) 59 { 60 if (!string.IsNullOrEmpty(fromProduct.VariantId)) 61 { 62 relateFromProductVariantIds.Add($"{fromProduct.Id} {fromProduct.VariantId}"); 63 } 64 else 65 { 66 relateFromProductVariantIds.Add($"{fromProduct.Id}"); 67 } 68 } 69 relateFromProductIds.Add($"{fromProduct.Id}"); 70 } 71 } 72 } 73 74 //--- GROUPS --- 75 if (sourceType == "most-sold" || sourceType == "trending" || sourceType == "latest" || sourceType == "custom") 76 { 77 var groupsToRelateTo = Model.Item.GetList("RelateTo")?.GetRawValue().OfType<string>().ToList(); 78 79 if (groupsToRelateTo != null) { 80 foreach (var fromGroup in groupsToRelateTo) 81 { 82 var groupId = fromGroup.Length > 2 ? fromGroup.Remove(0, 2) : fromGroup; 83 84 if (!fromGroup.Contains("p_")) 85 { 86 relateFromGroupIds.Add(groupId); 87 } 88 } 89 } 90 91 if (relateToViewModel?.Products != null) 92 { 93 foreach (var fromProduct in relateToViewModel.Products) 94 { 95 var groupId = fromProduct.PrimaryOrDefaultGroup.Id; 96 relateFromGroupIds.Add(groupId); 97 } 98 } 99 } 100 101 string relationGroupId = Model.Item.GetRawValueString("RelationGroup", string.Empty); 102 103 //--- RELATED GROUP --- 104 if (sourceType == "related") 105 { 106 if (relateToViewModel?.Products != null) 107 { 108 product = relateToViewModel.Products.FirstOrDefault(); 109 } 110 111 if (product?.RelatedGroups != null) 112 { 113 foreach (var relationGroup in product.RelatedGroups) 114 { 115 if (relationGroup.Id == relationGroupId) { 116 hasVariants = relationGroup.Products.Any(p => !string.IsNullOrEmpty(p.VariantId)); 117 foreach (var fromProduct in relationGroup.Products) 118 { 119 if (hasVariants) 120 { 121 if (!string.IsNullOrEmpty(fromProduct.VariantId)) 122 { 123 relateFromProductVariantIds.Add($"{fromProduct.ProductId} {fromProduct.VariantId}"); 124 } 125 else 126 { 127 relateFromProductVariantIds.Add($"{fromProduct.ProductId}"); 128 } 129 } 130 relateFromProductIds.Add($"{fromProduct.ProductId}"); 131 } 132 } 133 } 134 } 135 } 136 137 138 //Create group id collection and products id collection strings 139 string productIds = relateFromProductIds.Count > 0 ? string.Join(",", relateFromProductIds) : ""; 140 string productVariantIds = relateFromProductVariantIds.Count > 0 ? string.Join(",", relateFromProductVariantIds) : ""; 141 string groupIds = relateFromGroupIds.Count > 0 ? string.Join(",", relateFromGroupIds) : ""; 142 143 if (product is object) 144 { 145 if (string.IsNullOrEmpty(productIds) && (sourceType == "variants" || sourceType == "frequently" || sourceType == "selected" || sourceType == "custom")) 146 { 147 productIds = product.Id; 148 } 149 150 if (string.IsNullOrEmpty(groupIds) && (sourceType == "most-sold" || sourceType == "trending" || sourceType == "latest")) 151 { 152 groupIds = product.PrimaryOrDefaultGroup.Id; 153 } 154 } 155 } 156 157 @*Container element for the request*@ 158 @if (!string.IsNullOrEmpty(productIds) || !string.IsNullOrEmpty(groupIds) || (string.IsNullOrEmpty(productIds) && string.IsNullOrEmpty(groupIds) && sourceType != "related")) 159 { 160 <form method="post" action="@url" id="ComponentSliderProductsForm_@Model.ID" data-response-target-element="ComponentSliderProducts_@Model.ID" data-preloader="inline" data-update-url="false" class="item_@Model.Item.SystemName.ToLower()"> 161 <input type="hidden" name="ParagraphId" value="@Model.ID" /> 162 <input type="hidden" name="SortOrder" value="DESC"> 163 <input type="hidden" name="SourceType" value="@sourceType"> 164 165 @if (!string.IsNullOrEmpty(groupIds)) 166 { 167 <input type="hidden" name="GroupId" value="@groupIds"> 168 } 169 @if (sourceType != "frequently" && sourceType != "variants" && !string.IsNullOrEmpty(productIds) && !hasVariants) 170 { 171 <input type="hidden" name="MainProductId" value="@productIds"> 172 } 173 @if (sourceType != "frequently" && hasVariants) 174 { 175 <input type="hidden" name="ProductVariantId" value="@productVariantIds"> 176 } 177 178 @if (Model.Item.GetInt32("ProductsCount") != 0) 179 { 180 <input type="hidden" name="PageSize" value="@Model.Item.GetInt32("ProductsCount")"> 181 } 182 183 @if (sourceType == "variants") 184 { 185 <input type="hidden" name="MasterProductID" value="@productIds"> 186 <input type="hidden" name="isVariant" value="true"> 187 } 188 @if (sourceType == "most-sold") 189 { 190 <input type="hidden" name="SortBy" value="OrderCount"> 191 } 192 @if (sourceType == "trending") 193 { 194 <input type="hidden" name="SortBy" value="OrderCountGrowth"> 195 } 196 @if (sourceType == "frequently" && !string.IsNullOrEmpty(productIds)) 197 { 198 <input type="hidden" name="BoughtWithProductIds" value="[@productIds]"> 199 } 200 @if (sourceType == "latest") 201 { 202 <input type="hidden" name="SortBy" value="Created"> 203 } 204 </form> 205 206 <div class="w-100 h-100" data-dw-colorscheme="@Model.ColorScheme?.Id"> 207 <div id="ComponentSliderProducts_@Model.ID" class="h-100" style="@lazyHeight"></div> 208 </div> 209 210 <script type="module"> 211 const productSliderContainer = document.querySelector("#ComponentSliderProducts_@Model.ID"); 212 const productSliderForm = document.querySelector("#ComponentSliderProductsForm_@Model.ID"); 213 214 swift.PageUpdater.Update(productSliderForm); 215 productSliderForm.addEventListener("updated.swift.pageupdater", function(e){ 216 if (e.detail.html === "") { 217 productSliderContainer.closest("[data-col-size]").classList.add("d-none"); 218 } 219 }); 220 </script> 221 } 222 else if (Pageview.IsVisualEditorMode == true) 223 { 224 <div class="alert alert-dark" role="alert"> 225 <span>@Translate("Product component slider: The slider will be rendered here, if there is anything to show")</span> 226 </div> 227 } 228