Error executing template "/Designs/elsalg/frontpage/Paragraph/WidgetRaptorProductsNative.cshtml"
System.FormatException: Input string was not in a correct format.
at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
at System.Number.ParseDecimal(String value, NumberStyles options, NumberFormatInfo numfmt)
at System.Convert.ToDecimal(String value)
at CompiledRazorTemplates.Dynamic.RazorEngine_1e2993a8da144ee38d9a6d605f91b9de.Execute() in D:\websites\elsalg.dk\application(9.12.1)\Files\Templates\Designs\elsalg\frontpage\Paragraph\WidgetRaptorProductsNative.cshtml:line 164
at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer)
at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
at Dynamicweb.Rendering.Template.RenderRazorTemplate()
1 @using System.Net;
2 @using System.Web;
3 @using eela.custom;
4 @using eela.custom.Providers;
5 @using Newtonsoft.Json;
6 @using Newtonsoft.Json.Linq;
7 @using System.Text.RegularExpressions
8 @using Dynamicweb.Ecommerce;
9 @using Dynamicweb.Ecommerce.Products;
10 @using Dynamicweb.Ecommerce.Shops;
11 @{
12 var parameterName = GetValue("Item.SectionName") != null && !string.IsNullOrWhiteSpace(GetValue("Item.SectionName").ToString()) ? GetValue("Item.SectionName").ToString() : String.Empty;
13 var parameterValue = GetValue("Item.SectionValue") != null && !string.IsNullOrWhiteSpace(GetValue("Item.SectionValue").ToString()) ? GetValue("Item.SectionValue").ToString() : String.Empty;
14 var raptorIntegrationType = GetValue("Item.RaptorIntegrationType") != null && !string.IsNullOrWhiteSpace(GetValue("Item.RaptorIntegrationType").ToString()) ? GetValue("Item.RaptorIntegrationType").ToString() : "GetOverallTopVisits";
15
16 var productCount = GetValue("Item.NoOf_Products") != null && !string.IsNullOrWhiteSpace(GetValue("Item.NoOf_Products").ToString()) ? int.Parse(GetValue("Item.NoOf_Products").ToString()) : 10;
17
18 if (productCount < 1)
19 {
20 productCount = 10;
21
22 }
23
24 List<Dynamicweb.Ecommerce.Products.Product> products = new List<Dynamicweb.Ecommerce.Products.Product>();
25
26 if (raptorIntegrationType == "GetTopSellingInCagegory") { raptorIntegrationType = "GetTopSellingInCategory"; }
27 if (!string.IsNullOrWhiteSpace(parameterName) && !string.IsNullOrWhiteSpace(parameterValue))
28 {
29 products = eela.custom.Raptor.GetRaptorItems(raptorIntegrationType, parameterName, parameterValue, productCount);
30 }
31 else
32 {
33 products = eela.custom.Raptor.GetRaptorItems(raptorIntegrationType, productCount);
34 }
35
36 if (products.Count < 1) { return; }
37 }
38
39
40 <script>
41 function formatPrice(fPrice) {
42 document.write(fPrice.replace(/,00$/, ',-'));
43 }
44 $(document).ready(function () {
45 var $owlProducts = $('.owl-products');
46
47 function checkWidth() {
48 var windowSize = $(window).width();
49 if (windowSize > 1199) {
50 $owlProducts.owlCarousel({
51 margin: 24,
52 dots: false,
53 responsiveClass: true,
54 slideBy: "page",
55 responsive: {
56 0: {
57 items: 1,
58 nav: true
59 },
60 600: {
61 items: 3,
62 nav: true
63 },
64 1000: {
65 items: 4,
66 nav: true,
67 loop: false
68 }
69 }
70 });
71 $owlProducts.removeClass('scroll-mobile');
72 } else {
73 $owlProducts.addClass('scroll-mobile');
74 $owlProducts.owlCarousel('destroy');
75 }
76 }
77
78 checkWidth();
79
80 $(window).on("resize", checkWidth);
81
82 $(".item-assortment-link").on('click', function (event) {
83 event.preventDefault();
84 var newURl = $(this).attr('data-url');
85 location.href = newURl;
86 //window.open(newURl,'_blank');
87 });
88 });
89
90 </script>
91
92
93
94 <div class="widget-products">
95 <div class="container_4 clearfix">
96
97 <div class="title">
98 <div class="container_4 clearfix">
99 <div class="grid_4">
100 <h1>@GetString("Item.Title")</h1>
101 </div>
102 </div>
103 </div>
104
105 <div class="product-grid">
106 <div class="tabs-items tab-items-product">
107
108 <section class="tab-item current clearfix">
109
110 <div class="owl-wrapp">
111 <div id="raptor-recomendations-@raptorIntegrationType" class="owl-products owl-carousel owl-theme @(products.Count() < 4 ? "owl-center" : null)">
112 @foreach (Dynamicweb.Ecommerce.Products.Product product in products)
113 {
114 if (string.IsNullOrWhiteSpace(product.Name)) { continue; }
115
116 string price = product.GetPrice("DKK","DK").PriceWithVAT.ToString("0,0.00");
117 string priceDiscount = Services.Products.GetProductFieldValue(product, "ELSUnitSavings").ToString();
118 bool hasDiscount = false;
119 if (Convert.ToDecimal(priceDiscount) != 0)
120 {
121 hasDiscount = true;
122 }
123 string priceBefore = (hasDiscount) ? (Convert.ToDouble(priceDiscount) + Convert.ToDouble(price)).ToString() : "0";
124
125 string baseUrl = String.Format("Default.aspx?ID={0}&ProductID={1}", "9", product.Id);
126 string url = Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(baseUrl).ToString();
127 string buyURL = String.Format("{0}?cartcmd=add", url);
128
129 var primaryGroup = ProductProvider.GetPrimaryParentGroup(product.Id);
130 var elsEnergy = product.ProductFieldValues.GetProductFieldValue("ELSEnergy").Value.ToString();
131 var energyImgPath = ProductProvider.GetEnergyImagePath(product.ProductFieldValues.GetProductFieldValue("ELSEan").Value.ToString(), elsEnergy, primaryGroup.Id.Replace("-at-SHOP1", ""));
132
133 <div id="recomendation-@product.Id">
134 <article class="product @(hasDiscount ? "has-discount" : "")" title="@product.Name">
135 <div class="product-content">
136
137 <a class="clearfix product-link-box" href="@url" data-raptorrecommendation="productId:@product.Id">
138 <div class="image">
139 <div>
140 @if (!ProductProvider.ElectraImgExists(product.ProductFieldValues.GetProductFieldValue("ELSEan").Value.ToString(), product.Number))
141 {
142 <img src="https://cdn1.elsalg.dk/inetimagegen.ashx?altFmImage_path=/Files/ELSALG/eCom/Pictures/@(product.ProductFieldValues.GetProductFieldValue("ELSAlternatePictureID").Value.ToString() == "" ? "0000000000001" : product.ProductFieldValues.GetProductFieldValue("ELSAlternatePictureID").Value.ToString()).png&image=/files/ELSALG/eCom/Pictures/@(product.ProductFieldValues.GetProductFieldValue("ELSEan").Value.ToString()).png&width=255&height=255&crop=5" alt="@product.Name" />
143 }
144 else
145 {
146 var electraImgUrl = ProductProvider.GetElectraImgUrl(product.Number);
147
148 <img src="@electraImgUrl" alt="@product.Name" />
149 }
150 </div>
151
152 @*----- Render all labels related to the product notes. ----- *@
153
154 @{
155
156 var productSymbolsValue = product.ProductFieldValues.GetProductFieldValue("ELSProductSymbols").Value.ToString();
157 var elsAssortmentId = product.ProductFieldValues.GetProductFieldValue("ELSAssortmentID").Value.ToString().ToLower();
158
159
160 <div class="label-info">
161
162 @if (hasDiscount)
163 {
164 <div class="item save">@(Convert.ToDecimal("Spar " + Convert.ToDouble(priceDiscount).ToString("0,0.00").Replace(",00", ",-")))</div>
165 }
166
167 @if (!string.IsNullOrWhiteSpace(productSymbolsValue.Trim()))
168 {
169 var productSymbols = JArray.Parse(productSymbolsValue) as JArray;
170
171 foreach (var productSymbol in productSymbols)
172 {
173 <div class="item online">@productSymbol["description"]</div>
174 }
175 }
176
177 @if (elsAssortmentId == "5ps")
178 {
179 <div class="item rate">
180 Rente-og gebyrfrit
181 <span class="link item-assortment-link" data-url="/meddethele">
182 Læs mere her!
183 </span>
184 </div>
185 }
186 </div>
187
188 <div class="label-marks">
189 @if (!string.IsNullOrWhiteSpace(productSymbolsValue.Trim()))
190 {
191 var productSymbols = JArray.Parse(productSymbolsValue) as JArray;
192
193 foreach (var productSymbol in productSymbols)
194 {
195 <div class="item">
196 <img src="/files/images/symbols/@(productSymbol["value"])" alt="" />
197 </div>
198 }
199 }
200 </div>
201 }
202 </div>
203
204 <div class="text">
205 <div class="description">
206 <div class="title-content">
207 <div class="title">
208 @TruncateAtWords(product.Name.ToString(), 56)
209 </div>
210 <p class="productsubheader">
211 @product.ProductFieldValues.GetProductFieldValue("ELSProductSubHeader").Value
212 </p>
213 </div>
214 @product.ProductFieldValues.GetProductFieldValue("ELSProductShortText").Value
215
216 </div>
217 <div class="pricing clearfix">
218 <div class="prod-spec-tab d-flex justify-content-between"><a href="@string.Format("{0}?tab=specifications", url)">Produktdatablad</a>
219 @if (hasDiscount)
220 {
221 <span class="">Før @Convert.ToDouble(priceBefore).ToString("0,0.00").Replace(",00", ",-")</span>
222 }
223 </div>
224
225 <div class="clearfix">
226 <span class="discount">@("Spar " + Convert.ToDouble(priceDiscount).ToString("0,0.00").Replace(",00", ",-"))</span>
227 <span class="price">
228 <script>formatPrice('@ProductExtensions.GetCustomPrice(product)')</script>
229 @if (elsAssortmentId == "5ps")
230 {
231 <span class="month-price-text">Rentefrit pr. md.</span>
232 }
233 </span>
234 @if (!string.IsNullOrEmpty(energyImgPath))
235 {
236 <span class="energy-pg">
237 <a href="@string.Format("{0}?tab=specifications", url)">
238 <img src="@energyImgPath" alt="" />
239 </a>
240 </span>
241 }
242 <div class="buy">
243 <div onclick="AddToCartWithSupplemental('@buyURL', '@product.Number', '@product.Id', '@HttpUtility.JavaScriptStringEncode(product.Name.Replace("''", ""))');return false;" class="button skipSwipable">
244 Køb
245 </div>
246 </div>
247 </div>
248 <div class="delivery-text">@product.ProductFieldValues.GetProductFieldValue("ELSDeliveryText").Value.ToString()</div>
249 </div>
250 </div>
251 </a>
252 </div>
253 </article>
254 </div>
255 }
256 </div>
257 </div>
258 </section>
259 </div>
260 </div>
261 </div>
262 </div>
263
264 @functions
265 {
266 string TruncateAtWords(string html, int maxCharacters)
267 {
268 if (html == null || (html = html.Trim()).Length <= maxCharacters || string.IsNullOrEmpty(html))
269 return html;
270
271 int index = html.Trim().LastIndexOf(" ");
272 while ((index + 3) > maxCharacters)
273 index = html.Substring(0, index).Trim().LastIndexOf(" ");
274
275 if (index > 0)
276 return html.Substring(0, index) + " …";
277
278 return html.Substring(0, maxCharacters - 3) + " …";
279 }
280 }