Camilla Hamid

Camilla Hamid, en tvåbarnsmamma och hemkunskapslärare som startade bakbloggen My Kitchen Stories.

Numera är hon även en av Sveriges mest kända bakinfluencer med nästan 500 000 följare på IG, bakboksförfattare, poddare, bakproduktsdesigner, bakar på TV och på Youtube. Camilla har vunnit flera priser och utmärkelser men för henne är det självklart att baka, det har hon gjort sedan barnsben. ”Ska det fikas så ska det fikas ordentligt!” Gärna kladdiga kladdkakor, krämiga cheesecakes och generöst dekorerade bakverk. Till Dansukker har Camilla tagit fram recept där hon låtit klassiska svenska bakverk influeras av andra kulturer.

Instagram: @camillahamid

My Kitchen Stories

Camilla Hamid
Error executing template "Designs/Swift/Paragraph/RecipeInsertBlock.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_7ce4531f0a1e44cebc8275cfe494bfdb.<>c__DisplayClass0_0.<FindAndRenderProduct>b__0(TextWriter __razor_helper_writer) in E:\Dynamicweb.Net\Solutions\Dynamicweb\dansukker.prod\Swift-Files\Templates\Designs\Swift\Paragraph\RecipeInsertBlock.cshtml:line 35
   at CompiledRazorTemplates.Dynamic.RazorEngine_7ce4531f0a1e44cebc8275cfe494bfdb.Execute() in E:\Dynamicweb.Net\Solutions\Dynamicweb\dansukker.prod\Swift-Files\Templates\Designs\Swift\Paragraph\RecipeInsertBlock.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 Dynamicweb.Ecommerce.ProductCatalog 3 @using Dynamicweb.Extensibility 4 @using Dynamicweb.Indexing.Querying 5 @using Dynamicweb.Ecommerce 6 7 @{ 8 if (Model.Item.GetRawValueString("Product") == "") 9 { 10 return; 11 } 12 13 @* only ONE product, the first selected in the list, is rendered in this block*@ 14 string firstProductId = Model.Item.GetRawValueString("Product").Split(',')[0].Replace("p_", "").Replace(":", ""); 15 @FindAndRenderProduct(firstProductId); 16 } 17 18 19 @helper FindAndRenderProduct(string productId) 20 { 21 var queryService = ServiceLocator.Current.GetInstance<IQueryService>(); 22 var query = queryService.LoadQuery("All", "QueryAll.query"); 23 var settings = new QuerySettings 24 { 25 Skip = 0, 26 Take = 1, 27 Parameters = new Dictionary<string, object> 28 { 29 { "doctype", new[] { "Recipes" } }, 30 { "docID", new[] { productId } } 31 } 32 }; 33 var result = queryService.Query(query, settings); 34 35 foreach (Dictionary<string, object> document in result.QueryResult) 36 { 37 // Performance drawback when getting the product object from api service / DB for each recipe insert block, faster do display the data from the indexed document directly 38 // var product = Services.Products.GetProductById((string)document["ID"], "", Pageview.Area.EcomLanguageId); 39 40 Dynamicweb.Frontend.FileViewModel imageFile = new Dynamicweb.Frontend.FileViewModel(); 41 string imagePath = (string)@document["Image"] ?? ""; 42 imageFile.Path = imagePath; 43 44 string linkURL = "/Default.aspx?ID=" + GetPageIdByNavigationTag("Recipes") + "&productid=" + (string)document["ID"]; 45 46 <div class="h-100 position-relative mb-0-last-child"> 47 <div class="flex-fill mb-0-last-child"> 48 @RenderImage(imageFile, Model.Item) 49 @*TAGS COMMENTED OUT <div>@Translate("Recipe")</div>*@ 50 <h3 class="mb-2 h3 mw-75ch fw-bold">@document["Name"]</h3> 51 <div class="mb-3"> 52 <a href="@linkURL" class=" stretched-link"> 53 <span class="visually-hidden">@document["Name"]</span> 54 </a> 55 </div> 56 </div> 57 </div> 58 59 } 60 } 61 62 @helper RenderImage(Dynamicweb.Frontend.FileViewModel imageFile, Dynamicweb.Frontend.ItemViewModel item) 63 { 64 string ratioCssClass = Model.Item.GetRawValueString("ImageAspectRatio") != "0" && Model.Item.GetRawValueString("ImageAspectRatio") != "" ? "ratio" : ""; 65 string ratioVariable = Model.Item.GetRawValueString("ImageAspectRatio") != "0" && Model.Item.GetRawValueString("ImageAspectRatio") != "" ? "style=\"--bs-aspect-ratio: " + Model.Item.GetRawValueString("ImageAspectRatio") + "\"" : ""; 66 67 if (imageFile != null) 68 { 69 var parms = new Dictionary<string, object>(); 70 parms.Add("loading", "lazy"); 71 parms.Add("style", "cover"); 72 parms.Add("alt", ""); 73 parms.Add("columns", 5); 74 75 <figure class="@ratioCssClass" @ratioVariable> 76 @RenderPartial("Components/Image.cshtml", imageFile, parms) 77 </figure> 78 } 79 } 80 81
Error executing template "Designs/Swift/Paragraph/RecipeInsertBlock.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_7ce4531f0a1e44cebc8275cfe494bfdb.<>c__DisplayClass0_0.<FindAndRenderProduct>b__0(TextWriter __razor_helper_writer) in E:\Dynamicweb.Net\Solutions\Dynamicweb\dansukker.prod\Swift-Files\Templates\Designs\Swift\Paragraph\RecipeInsertBlock.cshtml:line 35
   at CompiledRazorTemplates.Dynamic.RazorEngine_7ce4531f0a1e44cebc8275cfe494bfdb.Execute() in E:\Dynamicweb.Net\Solutions\Dynamicweb\dansukker.prod\Swift-Files\Templates\Designs\Swift\Paragraph\RecipeInsertBlock.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 Dynamicweb.Ecommerce.ProductCatalog 3 @using Dynamicweb.Extensibility 4 @using Dynamicweb.Indexing.Querying 5 @using Dynamicweb.Ecommerce 6 7 @{ 8 if (Model.Item.GetRawValueString("Product") == "") 9 { 10 return; 11 } 12 13 @* only ONE product, the first selected in the list, is rendered in this block*@ 14 string firstProductId = Model.Item.GetRawValueString("Product").Split(',')[0].Replace("p_", "").Replace(":", ""); 15 @FindAndRenderProduct(firstProductId); 16 } 17 18 19 @helper FindAndRenderProduct(string productId) 20 { 21 var queryService = ServiceLocator.Current.GetInstance<IQueryService>(); 22 var query = queryService.LoadQuery("All", "QueryAll.query"); 23 var settings = new QuerySettings 24 { 25 Skip = 0, 26 Take = 1, 27 Parameters = new Dictionary<string, object> 28 { 29 { "doctype", new[] { "Recipes" } }, 30 { "docID", new[] { productId } } 31 } 32 }; 33 var result = queryService.Query(query, settings); 34 35 foreach (Dictionary<string, object> document in result.QueryResult) 36 { 37 // Performance drawback when getting the product object from api service / DB for each recipe insert block, faster do display the data from the indexed document directly 38 // var product = Services.Products.GetProductById((string)document["ID"], "", Pageview.Area.EcomLanguageId); 39 40 Dynamicweb.Frontend.FileViewModel imageFile = new Dynamicweb.Frontend.FileViewModel(); 41 string imagePath = (string)@document["Image"] ?? ""; 42 imageFile.Path = imagePath; 43 44 string linkURL = "/Default.aspx?ID=" + GetPageIdByNavigationTag("Recipes") + "&productid=" + (string)document["ID"]; 45 46 <div class="h-100 position-relative mb-0-last-child"> 47 <div class="flex-fill mb-0-last-child"> 48 @RenderImage(imageFile, Model.Item) 49 @*TAGS COMMENTED OUT <div>@Translate("Recipe")</div>*@ 50 <h3 class="mb-2 h3 mw-75ch fw-bold">@document["Name"]</h3> 51 <div class="mb-3"> 52 <a href="@linkURL" class=" stretched-link"> 53 <span class="visually-hidden">@document["Name"]</span> 54 </a> 55 </div> 56 </div> 57 </div> 58 59 } 60 } 61 62 @helper RenderImage(Dynamicweb.Frontend.FileViewModel imageFile, Dynamicweb.Frontend.ItemViewModel item) 63 { 64 string ratioCssClass = Model.Item.GetRawValueString("ImageAspectRatio") != "0" && Model.Item.GetRawValueString("ImageAspectRatio") != "" ? "ratio" : ""; 65 string ratioVariable = Model.Item.GetRawValueString("ImageAspectRatio") != "0" && Model.Item.GetRawValueString("ImageAspectRatio") != "" ? "style=\"--bs-aspect-ratio: " + Model.Item.GetRawValueString("ImageAspectRatio") + "\"" : ""; 66 67 if (imageFile != null) 68 { 69 var parms = new Dictionary<string, object>(); 70 parms.Add("loading", "lazy"); 71 parms.Add("style", "cover"); 72 parms.Add("alt", ""); 73 parms.Add("columns", 5); 74 75 <figure class="@ratioCssClass" @ratioVariable> 76 @RenderPartial("Components/Image.cshtml", imageFile, parms) 77 </figure> 78 } 79 } 80 81
Error executing template "Designs/Swift/Paragraph/RecipeInsertBlock.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_7ce4531f0a1e44cebc8275cfe494bfdb.<>c__DisplayClass0_0.<FindAndRenderProduct>b__0(TextWriter __razor_helper_writer) in E:\Dynamicweb.Net\Solutions\Dynamicweb\dansukker.prod\Swift-Files\Templates\Designs\Swift\Paragraph\RecipeInsertBlock.cshtml:line 35
   at CompiledRazorTemplates.Dynamic.RazorEngine_7ce4531f0a1e44cebc8275cfe494bfdb.Execute() in E:\Dynamicweb.Net\Solutions\Dynamicweb\dansukker.prod\Swift-Files\Templates\Designs\Swift\Paragraph\RecipeInsertBlock.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 Dynamicweb.Ecommerce.ProductCatalog 3 @using Dynamicweb.Extensibility 4 @using Dynamicweb.Indexing.Querying 5 @using Dynamicweb.Ecommerce 6 7 @{ 8 if (Model.Item.GetRawValueString("Product") == "") 9 { 10 return; 11 } 12 13 @* only ONE product, the first selected in the list, is rendered in this block*@ 14 string firstProductId = Model.Item.GetRawValueString("Product").Split(',')[0].Replace("p_", "").Replace(":", ""); 15 @FindAndRenderProduct(firstProductId); 16 } 17 18 19 @helper FindAndRenderProduct(string productId) 20 { 21 var queryService = ServiceLocator.Current.GetInstance<IQueryService>(); 22 var query = queryService.LoadQuery("All", "QueryAll.query"); 23 var settings = new QuerySettings 24 { 25 Skip = 0, 26 Take = 1, 27 Parameters = new Dictionary<string, object> 28 { 29 { "doctype", new[] { "Recipes" } }, 30 { "docID", new[] { productId } } 31 } 32 }; 33 var result = queryService.Query(query, settings); 34 35 foreach (Dictionary<string, object> document in result.QueryResult) 36 { 37 // Performance drawback when getting the product object from api service / DB for each recipe insert block, faster do display the data from the indexed document directly 38 // var product = Services.Products.GetProductById((string)document["ID"], "", Pageview.Area.EcomLanguageId); 39 40 Dynamicweb.Frontend.FileViewModel imageFile = new Dynamicweb.Frontend.FileViewModel(); 41 string imagePath = (string)@document["Image"] ?? ""; 42 imageFile.Path = imagePath; 43 44 string linkURL = "/Default.aspx?ID=" + GetPageIdByNavigationTag("Recipes") + "&productid=" + (string)document["ID"]; 45 46 <div class="h-100 position-relative mb-0-last-child"> 47 <div class="flex-fill mb-0-last-child"> 48 @RenderImage(imageFile, Model.Item) 49 @*TAGS COMMENTED OUT <div>@Translate("Recipe")</div>*@ 50 <h3 class="mb-2 h3 mw-75ch fw-bold">@document["Name"]</h3> 51 <div class="mb-3"> 52 <a href="@linkURL" class=" stretched-link"> 53 <span class="visually-hidden">@document["Name"]</span> 54 </a> 55 </div> 56 </div> 57 </div> 58 59 } 60 } 61 62 @helper RenderImage(Dynamicweb.Frontend.FileViewModel imageFile, Dynamicweb.Frontend.ItemViewModel item) 63 { 64 string ratioCssClass = Model.Item.GetRawValueString("ImageAspectRatio") != "0" && Model.Item.GetRawValueString("ImageAspectRatio") != "" ? "ratio" : ""; 65 string ratioVariable = Model.Item.GetRawValueString("ImageAspectRatio") != "0" && Model.Item.GetRawValueString("ImageAspectRatio") != "" ? "style=\"--bs-aspect-ratio: " + Model.Item.GetRawValueString("ImageAspectRatio") + "\"" : ""; 66 67 if (imageFile != null) 68 { 69 var parms = new Dictionary<string, object>(); 70 parms.Add("loading", "lazy"); 71 parms.Add("style", "cover"); 72 parms.Add("alt", ""); 73 parms.Add("columns", 5); 74 75 <figure class="@ratioCssClass" @ratioVariable> 76 @RenderPartial("Components/Image.cshtml", imageFile, parms) 77 </figure> 78 } 79 } 80 81
Error executing template "Designs/Swift/Paragraph/RecipeInsertBlock.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_7ce4531f0a1e44cebc8275cfe494bfdb.<>c__DisplayClass0_0.<FindAndRenderProduct>b__0(TextWriter __razor_helper_writer) in E:\Dynamicweb.Net\Solutions\Dynamicweb\dansukker.prod\Swift-Files\Templates\Designs\Swift\Paragraph\RecipeInsertBlock.cshtml:line 35
   at CompiledRazorTemplates.Dynamic.RazorEngine_7ce4531f0a1e44cebc8275cfe494bfdb.Execute() in E:\Dynamicweb.Net\Solutions\Dynamicweb\dansukker.prod\Swift-Files\Templates\Designs\Swift\Paragraph\RecipeInsertBlock.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 Dynamicweb.Ecommerce.ProductCatalog 3 @using Dynamicweb.Extensibility 4 @using Dynamicweb.Indexing.Querying 5 @using Dynamicweb.Ecommerce 6 7 @{ 8 if (Model.Item.GetRawValueString("Product") == "") 9 { 10 return; 11 } 12 13 @* only ONE product, the first selected in the list, is rendered in this block*@ 14 string firstProductId = Model.Item.GetRawValueString("Product").Split(',')[0].Replace("p_", "").Replace(":", ""); 15 @FindAndRenderProduct(firstProductId); 16 } 17 18 19 @helper FindAndRenderProduct(string productId) 20 { 21 var queryService = ServiceLocator.Current.GetInstance<IQueryService>(); 22 var query = queryService.LoadQuery("All", "QueryAll.query"); 23 var settings = new QuerySettings 24 { 25 Skip = 0, 26 Take = 1, 27 Parameters = new Dictionary<string, object> 28 { 29 { "doctype", new[] { "Recipes" } }, 30 { "docID", new[] { productId } } 31 } 32 }; 33 var result = queryService.Query(query, settings); 34 35 foreach (Dictionary<string, object> document in result.QueryResult) 36 { 37 // Performance drawback when getting the product object from api service / DB for each recipe insert block, faster do display the data from the indexed document directly 38 // var product = Services.Products.GetProductById((string)document["ID"], "", Pageview.Area.EcomLanguageId); 39 40 Dynamicweb.Frontend.FileViewModel imageFile = new Dynamicweb.Frontend.FileViewModel(); 41 string imagePath = (string)@document["Image"] ?? ""; 42 imageFile.Path = imagePath; 43 44 string linkURL = "/Default.aspx?ID=" + GetPageIdByNavigationTag("Recipes") + "&productid=" + (string)document["ID"]; 45 46 <div class="h-100 position-relative mb-0-last-child"> 47 <div class="flex-fill mb-0-last-child"> 48 @RenderImage(imageFile, Model.Item) 49 @*TAGS COMMENTED OUT <div>@Translate("Recipe")</div>*@ 50 <h3 class="mb-2 h3 mw-75ch fw-bold">@document["Name"]</h3> 51 <div class="mb-3"> 52 <a href="@linkURL" class=" stretched-link"> 53 <span class="visually-hidden">@document["Name"]</span> 54 </a> 55 </div> 56 </div> 57 </div> 58 59 } 60 } 61 62 @helper RenderImage(Dynamicweb.Frontend.FileViewModel imageFile, Dynamicweb.Frontend.ItemViewModel item) 63 { 64 string ratioCssClass = Model.Item.GetRawValueString("ImageAspectRatio") != "0" && Model.Item.GetRawValueString("ImageAspectRatio") != "" ? "ratio" : ""; 65 string ratioVariable = Model.Item.GetRawValueString("ImageAspectRatio") != "0" && Model.Item.GetRawValueString("ImageAspectRatio") != "" ? "style=\"--bs-aspect-ratio: " + Model.Item.GetRawValueString("ImageAspectRatio") + "\"" : ""; 66 67 if (imageFile != null) 68 { 69 var parms = new Dictionary<string, object>(); 70 parms.Add("loading", "lazy"); 71 parms.Add("style", "cover"); 72 parms.Add("alt", ""); 73 parms.Add("columns", 5); 74 75 <figure class="@ratioCssClass" @ratioVariable> 76 @RenderPartial("Components/Image.cshtml", imageFile, parms) 77 </figure> 78 } 79 } 80 81
Error executing template "Designs/Swift/Paragraph/RecipeInsertBlock.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_7ce4531f0a1e44cebc8275cfe494bfdb.<>c__DisplayClass0_0.<FindAndRenderProduct>b__0(TextWriter __razor_helper_writer) in E:\Dynamicweb.Net\Solutions\Dynamicweb\dansukker.prod\Swift-Files\Templates\Designs\Swift\Paragraph\RecipeInsertBlock.cshtml:line 35
   at CompiledRazorTemplates.Dynamic.RazorEngine_7ce4531f0a1e44cebc8275cfe494bfdb.Execute() in E:\Dynamicweb.Net\Solutions\Dynamicweb\dansukker.prod\Swift-Files\Templates\Designs\Swift\Paragraph\RecipeInsertBlock.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 Dynamicweb.Ecommerce.ProductCatalog 3 @using Dynamicweb.Extensibility 4 @using Dynamicweb.Indexing.Querying 5 @using Dynamicweb.Ecommerce 6 7 @{ 8 if (Model.Item.GetRawValueString("Product") == "") 9 { 10 return; 11 } 12 13 @* only ONE product, the first selected in the list, is rendered in this block*@ 14 string firstProductId = Model.Item.GetRawValueString("Product").Split(',')[0].Replace("p_", "").Replace(":", ""); 15 @FindAndRenderProduct(firstProductId); 16 } 17 18 19 @helper FindAndRenderProduct(string productId) 20 { 21 var queryService = ServiceLocator.Current.GetInstance<IQueryService>(); 22 var query = queryService.LoadQuery("All", "QueryAll.query"); 23 var settings = new QuerySettings 24 { 25 Skip = 0, 26 Take = 1, 27 Parameters = new Dictionary<string, object> 28 { 29 { "doctype", new[] { "Recipes" } }, 30 { "docID", new[] { productId } } 31 } 32 }; 33 var result = queryService.Query(query, settings); 34 35 foreach (Dictionary<string, object> document in result.QueryResult) 36 { 37 // Performance drawback when getting the product object from api service / DB for each recipe insert block, faster do display the data from the indexed document directly 38 // var product = Services.Products.GetProductById((string)document["ID"], "", Pageview.Area.EcomLanguageId); 39 40 Dynamicweb.Frontend.FileViewModel imageFile = new Dynamicweb.Frontend.FileViewModel(); 41 string imagePath = (string)@document["Image"] ?? ""; 42 imageFile.Path = imagePath; 43 44 string linkURL = "/Default.aspx?ID=" + GetPageIdByNavigationTag("Recipes") + "&productid=" + (string)document["ID"]; 45 46 <div class="h-100 position-relative mb-0-last-child"> 47 <div class="flex-fill mb-0-last-child"> 48 @RenderImage(imageFile, Model.Item) 49 @*TAGS COMMENTED OUT <div>@Translate("Recipe")</div>*@ 50 <h3 class="mb-2 h3 mw-75ch fw-bold">@document["Name"]</h3> 51 <div class="mb-3"> 52 <a href="@linkURL" class=" stretched-link"> 53 <span class="visually-hidden">@document["Name"]</span> 54 </a> 55 </div> 56 </div> 57 </div> 58 59 } 60 } 61 62 @helper RenderImage(Dynamicweb.Frontend.FileViewModel imageFile, Dynamicweb.Frontend.ItemViewModel item) 63 { 64 string ratioCssClass = Model.Item.GetRawValueString("ImageAspectRatio") != "0" && Model.Item.GetRawValueString("ImageAspectRatio") != "" ? "ratio" : ""; 65 string ratioVariable = Model.Item.GetRawValueString("ImageAspectRatio") != "0" && Model.Item.GetRawValueString("ImageAspectRatio") != "" ? "style=\"--bs-aspect-ratio: " + Model.Item.GetRawValueString("ImageAspectRatio") + "\"" : ""; 66 67 if (imageFile != null) 68 { 69 var parms = new Dictionary<string, object>(); 70 parms.Add("loading", "lazy"); 71 parms.Add("style", "cover"); 72 parms.Add("alt", ""); 73 parms.Add("columns", 5); 74 75 <figure class="@ratioCssClass" @ratioVariable> 76 @RenderPartial("Components/Image.cshtml", imageFile, parms) 77 </figure> 78 } 79 } 80 81
Error executing template "Designs/Swift/Paragraph/RecipeInsertBlock.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_7ce4531f0a1e44cebc8275cfe494bfdb.<>c__DisplayClass0_0.<FindAndRenderProduct>b__0(TextWriter __razor_helper_writer) in E:\Dynamicweb.Net\Solutions\Dynamicweb\dansukker.prod\Swift-Files\Templates\Designs\Swift\Paragraph\RecipeInsertBlock.cshtml:line 35
   at CompiledRazorTemplates.Dynamic.RazorEngine_7ce4531f0a1e44cebc8275cfe494bfdb.Execute() in E:\Dynamicweb.Net\Solutions\Dynamicweb\dansukker.prod\Swift-Files\Templates\Designs\Swift\Paragraph\RecipeInsertBlock.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 Dynamicweb.Ecommerce.ProductCatalog 3 @using Dynamicweb.Extensibility 4 @using Dynamicweb.Indexing.Querying 5 @using Dynamicweb.Ecommerce 6 7 @{ 8 if (Model.Item.GetRawValueString("Product") == "") 9 { 10 return; 11 } 12 13 @* only ONE product, the first selected in the list, is rendered in this block*@ 14 string firstProductId = Model.Item.GetRawValueString("Product").Split(',')[0].Replace("p_", "").Replace(":", ""); 15 @FindAndRenderProduct(firstProductId); 16 } 17 18 19 @helper FindAndRenderProduct(string productId) 20 { 21 var queryService = ServiceLocator.Current.GetInstance<IQueryService>(); 22 var query = queryService.LoadQuery("All", "QueryAll.query"); 23 var settings = new QuerySettings 24 { 25 Skip = 0, 26 Take = 1, 27 Parameters = new Dictionary<string, object> 28 { 29 { "doctype", new[] { "Recipes" } }, 30 { "docID", new[] { productId } } 31 } 32 }; 33 var result = queryService.Query(query, settings); 34 35 foreach (Dictionary<string, object> document in result.QueryResult) 36 { 37 // Performance drawback when getting the product object from api service / DB for each recipe insert block, faster do display the data from the indexed document directly 38 // var product = Services.Products.GetProductById((string)document["ID"], "", Pageview.Area.EcomLanguageId); 39 40 Dynamicweb.Frontend.FileViewModel imageFile = new Dynamicweb.Frontend.FileViewModel(); 41 string imagePath = (string)@document["Image"] ?? ""; 42 imageFile.Path = imagePath; 43 44 string linkURL = "/Default.aspx?ID=" + GetPageIdByNavigationTag("Recipes") + "&productid=" + (string)document["ID"]; 45 46 <div class="h-100 position-relative mb-0-last-child"> 47 <div class="flex-fill mb-0-last-child"> 48 @RenderImage(imageFile, Model.Item) 49 @*TAGS COMMENTED OUT <div>@Translate("Recipe")</div>*@ 50 <h3 class="mb-2 h3 mw-75ch fw-bold">@document["Name"]</h3> 51 <div class="mb-3"> 52 <a href="@linkURL" class=" stretched-link"> 53 <span class="visually-hidden">@document["Name"]</span> 54 </a> 55 </div> 56 </div> 57 </div> 58 59 } 60 } 61 62 @helper RenderImage(Dynamicweb.Frontend.FileViewModel imageFile, Dynamicweb.Frontend.ItemViewModel item) 63 { 64 string ratioCssClass = Model.Item.GetRawValueString("ImageAspectRatio") != "0" && Model.Item.GetRawValueString("ImageAspectRatio") != "" ? "ratio" : ""; 65 string ratioVariable = Model.Item.GetRawValueString("ImageAspectRatio") != "0" && Model.Item.GetRawValueString("ImageAspectRatio") != "" ? "style=\"--bs-aspect-ratio: " + Model.Item.GetRawValueString("ImageAspectRatio") + "\"" : ""; 66 67 if (imageFile != null) 68 { 69 var parms = new Dictionary<string, object>(); 70 parms.Add("loading", "lazy"); 71 parms.Add("style", "cover"); 72 parms.Add("alt", ""); 73 parms.Add("columns", 5); 74 75 <figure class="@ratioCssClass" @ratioVariable> 76 @RenderPartial("Components/Image.cshtml", imageFile, parms) 77 </figure> 78 } 79 } 80 81
Error executing template "Designs/Swift/Paragraph/RecipeInsertBlock.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_7ce4531f0a1e44cebc8275cfe494bfdb.<>c__DisplayClass0_0.<FindAndRenderProduct>b__0(TextWriter __razor_helper_writer) in E:\Dynamicweb.Net\Solutions\Dynamicweb\dansukker.prod\Swift-Files\Templates\Designs\Swift\Paragraph\RecipeInsertBlock.cshtml:line 35
   at CompiledRazorTemplates.Dynamic.RazorEngine_7ce4531f0a1e44cebc8275cfe494bfdb.Execute() in E:\Dynamicweb.Net\Solutions\Dynamicweb\dansukker.prod\Swift-Files\Templates\Designs\Swift\Paragraph\RecipeInsertBlock.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 Dynamicweb.Ecommerce.ProductCatalog 3 @using Dynamicweb.Extensibility 4 @using Dynamicweb.Indexing.Querying 5 @using Dynamicweb.Ecommerce 6 7 @{ 8 if (Model.Item.GetRawValueString("Product") == "") 9 { 10 return; 11 } 12 13 @* only ONE product, the first selected in the list, is rendered in this block*@ 14 string firstProductId = Model.Item.GetRawValueString("Product").Split(',')[0].Replace("p_", "").Replace(":", ""); 15 @FindAndRenderProduct(firstProductId); 16 } 17 18 19 @helper FindAndRenderProduct(string productId) 20 { 21 var queryService = ServiceLocator.Current.GetInstance<IQueryService>(); 22 var query = queryService.LoadQuery("All", "QueryAll.query"); 23 var settings = new QuerySettings 24 { 25 Skip = 0, 26 Take = 1, 27 Parameters = new Dictionary<string, object> 28 { 29 { "doctype", new[] { "Recipes" } }, 30 { "docID", new[] { productId } } 31 } 32 }; 33 var result = queryService.Query(query, settings); 34 35 foreach (Dictionary<string, object> document in result.QueryResult) 36 { 37 // Performance drawback when getting the product object from api service / DB for each recipe insert block, faster do display the data from the indexed document directly 38 // var product = Services.Products.GetProductById((string)document["ID"], "", Pageview.Area.EcomLanguageId); 39 40 Dynamicweb.Frontend.FileViewModel imageFile = new Dynamicweb.Frontend.FileViewModel(); 41 string imagePath = (string)@document["Image"] ?? ""; 42 imageFile.Path = imagePath; 43 44 string linkURL = "/Default.aspx?ID=" + GetPageIdByNavigationTag("Recipes") + "&productid=" + (string)document["ID"]; 45 46 <div class="h-100 position-relative mb-0-last-child"> 47 <div class="flex-fill mb-0-last-child"> 48 @RenderImage(imageFile, Model.Item) 49 @*TAGS COMMENTED OUT <div>@Translate("Recipe")</div>*@ 50 <h3 class="mb-2 h3 mw-75ch fw-bold">@document["Name"]</h3> 51 <div class="mb-3"> 52 <a href="@linkURL" class=" stretched-link"> 53 <span class="visually-hidden">@document["Name"]</span> 54 </a> 55 </div> 56 </div> 57 </div> 58 59 } 60 } 61 62 @helper RenderImage(Dynamicweb.Frontend.FileViewModel imageFile, Dynamicweb.Frontend.ItemViewModel item) 63 { 64 string ratioCssClass = Model.Item.GetRawValueString("ImageAspectRatio") != "0" && Model.Item.GetRawValueString("ImageAspectRatio") != "" ? "ratio" : ""; 65 string ratioVariable = Model.Item.GetRawValueString("ImageAspectRatio") != "0" && Model.Item.GetRawValueString("ImageAspectRatio") != "" ? "style=\"--bs-aspect-ratio: " + Model.Item.GetRawValueString("ImageAspectRatio") + "\"" : ""; 66 67 if (imageFile != null) 68 { 69 var parms = new Dictionary<string, object>(); 70 parms.Add("loading", "lazy"); 71 parms.Add("style", "cover"); 72 parms.Add("alt", ""); 73 parms.Add("columns", 5); 74 75 <figure class="@ratioCssClass" @ratioVariable> 76 @RenderPartial("Components/Image.cshtml", imageFile, parms) 77 </figure> 78 } 79 } 80 81
Error executing template "Designs/Swift/Paragraph/RecipeInsertBlock.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_7ce4531f0a1e44cebc8275cfe494bfdb.<>c__DisplayClass0_0.<FindAndRenderProduct>b__0(TextWriter __razor_helper_writer) in E:\Dynamicweb.Net\Solutions\Dynamicweb\dansukker.prod\Swift-Files\Templates\Designs\Swift\Paragraph\RecipeInsertBlock.cshtml:line 35
   at CompiledRazorTemplates.Dynamic.RazorEngine_7ce4531f0a1e44cebc8275cfe494bfdb.Execute() in E:\Dynamicweb.Net\Solutions\Dynamicweb\dansukker.prod\Swift-Files\Templates\Designs\Swift\Paragraph\RecipeInsertBlock.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 Dynamicweb.Ecommerce.ProductCatalog 3 @using Dynamicweb.Extensibility 4 @using Dynamicweb.Indexing.Querying 5 @using Dynamicweb.Ecommerce 6 7 @{ 8 if (Model.Item.GetRawValueString("Product") == "") 9 { 10 return; 11 } 12 13 @* only ONE product, the first selected in the list, is rendered in this block*@ 14 string firstProductId = Model.Item.GetRawValueString("Product").Split(',')[0].Replace("p_", "").Replace(":", ""); 15 @FindAndRenderProduct(firstProductId); 16 } 17 18 19 @helper FindAndRenderProduct(string productId) 20 { 21 var queryService = ServiceLocator.Current.GetInstance<IQueryService>(); 22 var query = queryService.LoadQuery("All", "QueryAll.query"); 23 var settings = new QuerySettings 24 { 25 Skip = 0, 26 Take = 1, 27 Parameters = new Dictionary<string, object> 28 { 29 { "doctype", new[] { "Recipes" } }, 30 { "docID", new[] { productId } } 31 } 32 }; 33 var result = queryService.Query(query, settings); 34 35 foreach (Dictionary<string, object> document in result.QueryResult) 36 { 37 // Performance drawback when getting the product object from api service / DB for each recipe insert block, faster do display the data from the indexed document directly 38 // var product = Services.Products.GetProductById((string)document["ID"], "", Pageview.Area.EcomLanguageId); 39 40 Dynamicweb.Frontend.FileViewModel imageFile = new Dynamicweb.Frontend.FileViewModel(); 41 string imagePath = (string)@document["Image"] ?? ""; 42 imageFile.Path = imagePath; 43 44 string linkURL = "/Default.aspx?ID=" + GetPageIdByNavigationTag("Recipes") + "&productid=" + (string)document["ID"]; 45 46 <div class="h-100 position-relative mb-0-last-child"> 47 <div class="flex-fill mb-0-last-child"> 48 @RenderImage(imageFile, Model.Item) 49 @*TAGS COMMENTED OUT <div>@Translate("Recipe")</div>*@ 50 <h3 class="mb-2 h3 mw-75ch fw-bold">@document["Name"]</h3> 51 <div class="mb-3"> 52 <a href="@linkURL" class=" stretched-link"> 53 <span class="visually-hidden">@document["Name"]</span> 54 </a> 55 </div> 56 </div> 57 </div> 58 59 } 60 } 61 62 @helper RenderImage(Dynamicweb.Frontend.FileViewModel imageFile, Dynamicweb.Frontend.ItemViewModel item) 63 { 64 string ratioCssClass = Model.Item.GetRawValueString("ImageAspectRatio") != "0" && Model.Item.GetRawValueString("ImageAspectRatio") != "" ? "ratio" : ""; 65 string ratioVariable = Model.Item.GetRawValueString("ImageAspectRatio") != "0" && Model.Item.GetRawValueString("ImageAspectRatio") != "" ? "style=\"--bs-aspect-ratio: " + Model.Item.GetRawValueString("ImageAspectRatio") + "\"" : ""; 66 67 if (imageFile != null) 68 { 69 var parms = new Dictionary<string, object>(); 70 parms.Add("loading", "lazy"); 71 parms.Add("style", "cover"); 72 parms.Add("alt", ""); 73 parms.Add("columns", 5); 74 75 <figure class="@ratioCssClass" @ratioVariable> 76 @RenderPartial("Components/Image.cshtml", imageFile, parms) 77 </figure> 78 } 79 } 80 81
Error executing template "Designs/Swift/Paragraph/RecipeInsertBlock.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_7ce4531f0a1e44cebc8275cfe494bfdb.<>c__DisplayClass0_0.<FindAndRenderProduct>b__0(TextWriter __razor_helper_writer) in E:\Dynamicweb.Net\Solutions\Dynamicweb\dansukker.prod\Swift-Files\Templates\Designs\Swift\Paragraph\RecipeInsertBlock.cshtml:line 35
   at CompiledRazorTemplates.Dynamic.RazorEngine_7ce4531f0a1e44cebc8275cfe494bfdb.Execute() in E:\Dynamicweb.Net\Solutions\Dynamicweb\dansukker.prod\Swift-Files\Templates\Designs\Swift\Paragraph\RecipeInsertBlock.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 Dynamicweb.Ecommerce.ProductCatalog 3 @using Dynamicweb.Extensibility 4 @using Dynamicweb.Indexing.Querying 5 @using Dynamicweb.Ecommerce 6 7 @{ 8 if (Model.Item.GetRawValueString("Product") == "") 9 { 10 return; 11 } 12 13 @* only ONE product, the first selected in the list, is rendered in this block*@ 14 string firstProductId = Model.Item.GetRawValueString("Product").Split(',')[0].Replace("p_", "").Replace(":", ""); 15 @FindAndRenderProduct(firstProductId); 16 } 17 18 19 @helper FindAndRenderProduct(string productId) 20 { 21 var queryService = ServiceLocator.Current.GetInstance<IQueryService>(); 22 var query = queryService.LoadQuery("All", "QueryAll.query"); 23 var settings = new QuerySettings 24 { 25 Skip = 0, 26 Take = 1, 27 Parameters = new Dictionary<string, object> 28 { 29 { "doctype", new[] { "Recipes" } }, 30 { "docID", new[] { productId } } 31 } 32 }; 33 var result = queryService.Query(query, settings); 34 35 foreach (Dictionary<string, object> document in result.QueryResult) 36 { 37 // Performance drawback when getting the product object from api service / DB for each recipe insert block, faster do display the data from the indexed document directly 38 // var product = Services.Products.GetProductById((string)document["ID"], "", Pageview.Area.EcomLanguageId); 39 40 Dynamicweb.Frontend.FileViewModel imageFile = new Dynamicweb.Frontend.FileViewModel(); 41 string imagePath = (string)@document["Image"] ?? ""; 42 imageFile.Path = imagePath; 43 44 string linkURL = "/Default.aspx?ID=" + GetPageIdByNavigationTag("Recipes") + "&productid=" + (string)document["ID"]; 45 46 <div class="h-100 position-relative mb-0-last-child"> 47 <div class="flex-fill mb-0-last-child"> 48 @RenderImage(imageFile, Model.Item) 49 @*TAGS COMMENTED OUT <div>@Translate("Recipe")</div>*@ 50 <h3 class="mb-2 h3 mw-75ch fw-bold">@document["Name"]</h3> 51 <div class="mb-3"> 52 <a href="@linkURL" class=" stretched-link"> 53 <span class="visually-hidden">@document["Name"]</span> 54 </a> 55 </div> 56 </div> 57 </div> 58 59 } 60 } 61 62 @helper RenderImage(Dynamicweb.Frontend.FileViewModel imageFile, Dynamicweb.Frontend.ItemViewModel item) 63 { 64 string ratioCssClass = Model.Item.GetRawValueString("ImageAspectRatio") != "0" && Model.Item.GetRawValueString("ImageAspectRatio") != "" ? "ratio" : ""; 65 string ratioVariable = Model.Item.GetRawValueString("ImageAspectRatio") != "0" && Model.Item.GetRawValueString("ImageAspectRatio") != "" ? "style=\"--bs-aspect-ratio: " + Model.Item.GetRawValueString("ImageAspectRatio") + "\"" : ""; 66 67 if (imageFile != null) 68 { 69 var parms = new Dictionary<string, object>(); 70 parms.Add("loading", "lazy"); 71 parms.Add("style", "cover"); 72 parms.Add("alt", ""); 73 parms.Add("columns", 5); 74 75 <figure class="@ratioCssClass" @ratioVariable> 76 @RenderPartial("Components/Image.cshtml", imageFile, parms) 77 </figure> 78 } 79 } 80 81
Error executing template "Designs/Swift/Paragraph/RecipeInsertBlock.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_7ce4531f0a1e44cebc8275cfe494bfdb.<>c__DisplayClass0_0.<FindAndRenderProduct>b__0(TextWriter __razor_helper_writer) in E:\Dynamicweb.Net\Solutions\Dynamicweb\dansukker.prod\Swift-Files\Templates\Designs\Swift\Paragraph\RecipeInsertBlock.cshtml:line 35
   at CompiledRazorTemplates.Dynamic.RazorEngine_7ce4531f0a1e44cebc8275cfe494bfdb.Execute() in E:\Dynamicweb.Net\Solutions\Dynamicweb\dansukker.prod\Swift-Files\Templates\Designs\Swift\Paragraph\RecipeInsertBlock.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 Dynamicweb.Ecommerce.ProductCatalog 3 @using Dynamicweb.Extensibility 4 @using Dynamicweb.Indexing.Querying 5 @using Dynamicweb.Ecommerce 6 7 @{ 8 if (Model.Item.GetRawValueString("Product") == "") 9 { 10 return; 11 } 12 13 @* only ONE product, the first selected in the list, is rendered in this block*@ 14 string firstProductId = Model.Item.GetRawValueString("Product").Split(',')[0].Replace("p_", "").Replace(":", ""); 15 @FindAndRenderProduct(firstProductId); 16 } 17 18 19 @helper FindAndRenderProduct(string productId) 20 { 21 var queryService = ServiceLocator.Current.GetInstance<IQueryService>(); 22 var query = queryService.LoadQuery("All", "QueryAll.query"); 23 var settings = new QuerySettings 24 { 25 Skip = 0, 26 Take = 1, 27 Parameters = new Dictionary<string, object> 28 { 29 { "doctype", new[] { "Recipes" } }, 30 { "docID", new[] { productId } } 31 } 32 }; 33 var result = queryService.Query(query, settings); 34 35 foreach (Dictionary<string, object> document in result.QueryResult) 36 { 37 // Performance drawback when getting the product object from api service / DB for each recipe insert block, faster do display the data from the indexed document directly 38 // var product = Services.Products.GetProductById((string)document["ID"], "", Pageview.Area.EcomLanguageId); 39 40 Dynamicweb.Frontend.FileViewModel imageFile = new Dynamicweb.Frontend.FileViewModel(); 41 string imagePath = (string)@document["Image"] ?? ""; 42 imageFile.Path = imagePath; 43 44 string linkURL = "/Default.aspx?ID=" + GetPageIdByNavigationTag("Recipes") + "&productid=" + (string)document["ID"]; 45 46 <div class="h-100 position-relative mb-0-last-child"> 47 <div class="flex-fill mb-0-last-child"> 48 @RenderImage(imageFile, Model.Item) 49 @*TAGS COMMENTED OUT <div>@Translate("Recipe")</div>*@ 50 <h3 class="mb-2 h3 mw-75ch fw-bold">@document["Name"]</h3> 51 <div class="mb-3"> 52 <a href="@linkURL" class=" stretched-link"> 53 <span class="visually-hidden">@document["Name"]</span> 54 </a> 55 </div> 56 </div> 57 </div> 58 59 } 60 } 61 62 @helper RenderImage(Dynamicweb.Frontend.FileViewModel imageFile, Dynamicweb.Frontend.ItemViewModel item) 63 { 64 string ratioCssClass = Model.Item.GetRawValueString("ImageAspectRatio") != "0" && Model.Item.GetRawValueString("ImageAspectRatio") != "" ? "ratio" : ""; 65 string ratioVariable = Model.Item.GetRawValueString("ImageAspectRatio") != "0" && Model.Item.GetRawValueString("ImageAspectRatio") != "" ? "style=\"--bs-aspect-ratio: " + Model.Item.GetRawValueString("ImageAspectRatio") + "\"" : ""; 66 67 if (imageFile != null) 68 { 69 var parms = new Dictionary<string, object>(); 70 parms.Add("loading", "lazy"); 71 parms.Add("style", "cover"); 72 parms.Add("alt", ""); 73 parms.Add("columns", 5); 74 75 <figure class="@ratioCssClass" @ratioVariable> 76 @RenderPartial("Components/Image.cshtml", imageFile, parms) 77 </figure> 78 } 79 } 80 81
Error executing template "Designs/Swift/Paragraph/RecipeInsertBlock.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_7ce4531f0a1e44cebc8275cfe494bfdb.<>c__DisplayClass0_0.<FindAndRenderProduct>b__0(TextWriter __razor_helper_writer) in E:\Dynamicweb.Net\Solutions\Dynamicweb\dansukker.prod\Swift-Files\Templates\Designs\Swift\Paragraph\RecipeInsertBlock.cshtml:line 35
   at CompiledRazorTemplates.Dynamic.RazorEngine_7ce4531f0a1e44cebc8275cfe494bfdb.Execute() in E:\Dynamicweb.Net\Solutions\Dynamicweb\dansukker.prod\Swift-Files\Templates\Designs\Swift\Paragraph\RecipeInsertBlock.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 Dynamicweb.Ecommerce.ProductCatalog 3 @using Dynamicweb.Extensibility 4 @using Dynamicweb.Indexing.Querying 5 @using Dynamicweb.Ecommerce 6 7 @{ 8 if (Model.Item.GetRawValueString("Product") == "") 9 { 10 return; 11 } 12 13 @* only ONE product, the first selected in the list, is rendered in this block*@ 14 string firstProductId = Model.Item.GetRawValueString("Product").Split(',')[0].Replace("p_", "").Replace(":", ""); 15 @FindAndRenderProduct(firstProductId); 16 } 17 18 19 @helper FindAndRenderProduct(string productId) 20 { 21 var queryService = ServiceLocator.Current.GetInstance<IQueryService>(); 22 var query = queryService.LoadQuery("All", "QueryAll.query"); 23 var settings = new QuerySettings 24 { 25 Skip = 0, 26 Take = 1, 27 Parameters = new Dictionary<string, object> 28 { 29 { "doctype", new[] { "Recipes" } }, 30 { "docID", new[] { productId } } 31 } 32 }; 33 var result = queryService.Query(query, settings); 34 35 foreach (Dictionary<string, object> document in result.QueryResult) 36 { 37 // Performance drawback when getting the product object from api service / DB for each recipe insert block, faster do display the data from the indexed document directly 38 // var product = Services.Products.GetProductById((string)document["ID"], "", Pageview.Area.EcomLanguageId); 39 40 Dynamicweb.Frontend.FileViewModel imageFile = new Dynamicweb.Frontend.FileViewModel(); 41 string imagePath = (string)@document["Image"] ?? ""; 42 imageFile.Path = imagePath; 43 44 string linkURL = "/Default.aspx?ID=" + GetPageIdByNavigationTag("Recipes") + "&productid=" + (string)document["ID"]; 45 46 <div class="h-100 position-relative mb-0-last-child"> 47 <div class="flex-fill mb-0-last-child"> 48 @RenderImage(imageFile, Model.Item) 49 @*TAGS COMMENTED OUT <div>@Translate("Recipe")</div>*@ 50 <h3 class="mb-2 h3 mw-75ch fw-bold">@document["Name"]</h3> 51 <div class="mb-3"> 52 <a href="@linkURL" class=" stretched-link"> 53 <span class="visually-hidden">@document["Name"]</span> 54 </a> 55 </div> 56 </div> 57 </div> 58 59 } 60 } 61 62 @helper RenderImage(Dynamicweb.Frontend.FileViewModel imageFile, Dynamicweb.Frontend.ItemViewModel item) 63 { 64 string ratioCssClass = Model.Item.GetRawValueString("ImageAspectRatio") != "0" && Model.Item.GetRawValueString("ImageAspectRatio") != "" ? "ratio" : ""; 65 string ratioVariable = Model.Item.GetRawValueString("ImageAspectRatio") != "0" && Model.Item.GetRawValueString("ImageAspectRatio") != "" ? "style=\"--bs-aspect-ratio: " + Model.Item.GetRawValueString("ImageAspectRatio") + "\"" : ""; 66 67 if (imageFile != null) 68 { 69 var parms = new Dictionary<string, object>(); 70 parms.Add("loading", "lazy"); 71 parms.Add("style", "cover"); 72 parms.Add("alt", ""); 73 parms.Add("columns", 5); 74 75 <figure class="@ratioCssClass" @ratioVariable> 76 @RenderPartial("Components/Image.cshtml", imageFile, parms) 77 </figure> 78 } 79 } 80 81

Har du några frågor rörande våra produkter, recept eller annat så svarar vi gärna.

Baka med sommarens bär

Baka med sommarens bär och bjud på något hembakat till kalaset.

Magiskt god Morotsbulle med frosting

Elsa Billgren och Sofia Wood har tagit fram ett helt nytt bakverk som är härligt saftigt, goffigt, kryddigt och alldeles underbart. Ett recept du inte vill missa!

Härliga jordgubbstider

Låt dig inspireras av våra recept med jordgubbar som ingrediens.

Gör din egen glass

Här har vi samlat våra bästa glassrecept, men experimentera gärna fram dina egna favoriter!

Syltskolan

I vår Syltskola hittar du alla tips om hur du kokar sylt, frågor och svar och recept.

Sommardesserter

När det är varmt är det extra gott att bjuda på en sötsyrlig och fräsch sommardessert som avslutning på grillkvällen eller sommarfesten.