Error executing template "Designs/Rapido/eCom/ProductCatalog/SpReorderPricesAjax.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_9578b8b1dbfd47a780b7f497b5211725.Execute() in D:\Dynamicweb.net\Solutions\frellsen.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\eCom\ProductCatalog\SpReorderPricesAjax.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 ViewModelTemplate<ProductListViewModel> 2 @using Dynamicweb.Rendering 3 @using Dynamicweb.Ecommerce.ProductCatalog 4 @using Smartpage.Frellsen.Reorder 5 @using Dynamicweb.Core 6 @using System.Globalization 7 @using System.Web; 8 @using System.Linq; 9 @using Dynamicweb.Ecommerce.Products 10 @using Smartpage.Frellsen.Reorder.Models 11 12 @{ 13 Dynamicweb.Ecommerce.International.CurrencyService currencyService = new Dynamicweb.Ecommerce.International.CurrencyService(); 14 var currentUser = Dynamicweb.Security.UserManagement.User.GetCurrentExtranetUser(); 15 var currency = currencyService.GetCurrency(currentUser.Currency); 16 var getPrices = HttpContext.Current.Request.QueryString.Get("getprices"); 17 18 if (currency == null) 19 { 20 currency = currencyService.GetDefaultCurrency(); 21 } 22 23 if (!string.IsNullOrEmpty(getPrices)) 24 { 25 string[] productIds = getPrices.Split(','); 26 27 foreach (string productId in productIds) 28 { 29 var pricePrKg = 0.0; 30 var priceUnit = 0; 31 var product = Model.Products.Single(x => x.Number == productId); 32 var price = product.Price; // Activate dynamicweb to lazy load prices to have productInfo loaded in liveintegration (viewmodel) 33 var apiProduct = Dynamicweb.Ecommerce.Services.Products.GetProductById(productId, "", Dynamicweb.Ecommerce.Common.Context.LanguageID); 34 if (apiProduct != null) 35 { 36 var productInfo = Dynamicweb.Ecommerce.LiveIntegration.Products.ProductManager.GetProductInfo(apiProduct); 37 if (productInfo != null) 38 { 39 pricePrKg = Converter.ToDouble(productInfo["SpPricePrKg"]); 40 priceUnit = Converter.ToInt32(productInfo["SpPriceUnit"]); 41 } 42 } 43 44 <div class="box-price" data-productid="@productId"> 45 <p class="u-bold u-margin-bottom">@product.Price.PriceFormatted</p> 46 47 @if (pricePrKg > 0.0) 48 { 49 <small class="u-no-margin u-color-font-black">@Translate("Pris pr. kg"):<strong> @currencyService.FormatCurrency(currency, pricePrKg, true)</strong></small> 50 } 51 </div> 52 } 53 } 54 55 }