Error executing template "Designs/duroc/eCom/Product/espresso.cshtml"
System.ArgumentOutOfRangeException: Index and length must refer to a location within the string.
Parameter name: length
at System.String.Substring(Int32 startIndex, Int32 length)
at CompiledRazorTemplates.Dynamic.RazorEngine_6f08d94e6d934900be816dd2bc3ed140.Execute() in E:\Dynamicweb.NET\Solutions\duroc.espresso4.dk\Files\Templates\Designs\duroc\eCom\Product\espresso.cshtml:line 40
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.b__0(TextWriter writer)
at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
at Dynamicweb.Rendering.Template.RenderRazorTemplate()
1 @inherits Co3.Espresso.Website.TemplateBases.Paragraphs.Module
2 @using System.Web
3 @using Co3.duroc.Website.Models.Frontend.Ecommerce
4 @using Co3.Espresso.Base.Extensions
5 @using Co3.Espresso.Website.Services
6 @using Co3.Espresso.Website.Models.FrontEnd
7 @using Co3.Espresso.Website.Models.FrontEnd.Settings
8 @using Co3.Espresso.Website.Models.FrontEnd.Ecommerce
9 @using Co3.Espresso.Website.Models.FrontEnd.Handlebars
10 @using Dynamicweb
11 @using Dynamicweb.Content
12 @using Dynamicweb.Core
13 @using Dynamicweb.Frontend
14 @using Dynamicweb.Security.UserManagement
15 @using Dynamicweb.UI.Elements.Layouts
16 @using Context = Dynamicweb.Ecommerce.Common.Context
17 @using IPageService = Co3.Espresso.Website.Services.IPageService
18 @using PageService = Dynamicweb.Content.PageService
19
20 @{
21 bool isUserAuthenticated = User.IsExtranetUserLoggedIn();
22 DurocProduct espressoProduct = ProductService.Instance.GetEspressoProduct(
23 new ProductSettings()
24 {
25 Id = GetString("Ecom:Product.ID"),
26 VariantId = GetString("Ecom:Product.VariantID"),
27 PrimaryVariantId = GetString("Ecom:Product.DefaultVariantComboID")
28 }
29 ) as DurocProduct;
30
31 string metaDescription = "";
32 if (!string.IsNullOrEmpty(espressoProduct.DescriptionShort))
33 {
34 metaDescription = espressoProduct.DescriptionShort;
35 metaDescription = metaDescription.StripHtml().Substring(0, 150);
36 }
37 else if (!string.IsNullOrEmpty(espressoProduct.DescriptionLong))
38 {
39 metaDescription = espressoProduct.DescriptionLong;
40 metaDescription = metaDescription.StripHtml().Substring(0, 150);
41 }
42 }
43
44 @RenderingService.Instance.SectionEnd()
45
46 @SnippetStart( "productDescription" )
47 @if (!espressoProduct.IsMainProduct)
48 {
49 <meta name="robots" content="noindex, nofollow">
50 }
51 @if ( GetString( "Ecom:Product.MetaDescription" ) != "" )
52 {
53 <meta name="description" content="@GetString( "Ecom:Product.MetaDescription" )">
54 }
55 else
56 {
57 <meta name="description" content="@metaDescription">
58 }
59 @SnippetEnd( "productDescription" )
60
61 <div class="e-product js-e-product" data-product-id="@espressoProduct.Id" data-has-variants="@espressoProduct.HasVariants.ToString().ToLower()" data-variant-id="@espressoProduct.VariantId">
62
63 @RenderingService.Instance.SectionStart( new SectionSettings
64 {
65 Classes = new ClassList( "e-section pb-2" )
66 } )
67 <div class="col-12">
68 <div class="row">
69 <div class="col-12">
70 <h1 class="e-product-name mb-1">
71 @espressoProduct.Brand @espressoProduct.Name
72 </h1>
73 </div>
74 </div>
75 <div class="row">
76 <div class="col-12 col-sm-5">
77 <div class="row mb-2">
78 @if (!string.IsNullOrEmpty(espressoProduct.DescriptionLong))
79 {
80 @RenderingService.Instance.SectionStart(new SectionSettings
81 {
82 Classes = new ClassList("col-12"),
83 ContentClasses = new ClassList("col-12"),
84 Collapsible = true
85 })
86
87 @espressoProduct.DescriptionLong
88
89 @RenderingService.Instance.SectionEnd()
90 }
91 else
92 {
93 <div class="col-12">
94 <div class="e-product-text mb-2">
95 @espressoProduct.DescriptionShort
96 </div>
97 </div>
98 }
99 </div>
100 @*
101 <div class="row">
102 <div class="col-12">
103 <div class="e-product-delivery mb-2">
104 @RenderingService.Instance.PartialView("ecom/product/partials/delivery-info.cshtml", espressoProduct)
105 </div>
106 </div>
107 </div>*@
108 @if (espressoProduct.ContactPersonProductDescriptionId > 0)
109 {
110 <div class="row e-product-contact-person">
111 @RenderPageContent(espressoProduct.ContactPersonProductDescriptionId)
112 </div>
113
114 // If we have a contact or catalogue section, let's link to them
115 if (espressoProduct.ContactPersonId > 0 || espressoProduct.PdfList.Count >= 0 )
116 {
117 <div class="e-product-contact-buttons">
118 @if (espressoProduct.ContactPersonId > 0)
119 {
120 <a href="@(PageView.Current().SearchFriendlyUrl)#@(espressoProduct.ContactPersonAnchorId)" class="btn btn-primary">@Translate("Product - Description - Contact Button", "Tag kontakt")</a>
121 }
122 @if (espressoProduct.PdfList.Count >= 0)
123 {
124 <a href="@(PageView.Current().SearchFriendlyUrl)#catalogues" class="btn btn-secondary">@Translate("Product - Description - Get Catalogue Button", "Hent katalog")</a>
125 }
126 </div>
127 }
128 }
129 </div>
130
131 <div class="col-12 col-sm-7 order-first">
132 @RenderingService.Instance.PartialView("ecom/product/partials/images.cshtml", espressoProduct)
133 </div>
134 </div>
135 </div>
136 @RenderingService.Instance.SectionEnd()
137
138 @if (espressoProduct.OperationVideoLink.IsNotNullOrEmpty() || espressoProduct.DemonstrationVideoLink.IsNotNullOrEmpty())
139 {
140 <section class="e-section">
141 <div class="container-fluid">
142 <div class="row">
143 <div class="col-12">
144 <p class="h2">@Translate("Product - Video - Heading", "Betjening og demonstration")</p>
145 </div>
146 </div>
147 <div class="row">
148 @if (espressoProduct.OperationVideoLink.IsNotNullOrEmpty())
149 {
150 <div class="p p-video p-width-auto col-12 col-sm-12 col-md-6">
151 <div class="row">
152 <div class="p-video-container mb-1 col-12 order-first">
153 <div class="embed-responsive embed-responsive-16by9">
154 <iframe class="embed-responsive-item" src="@espressoProduct.OperationVideoLink" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen="" width="1080" height="608" frameborder="0"></iframe>
155 </div>
156 </div>
157 </div>
158 </div>
159 }
160 @if (espressoProduct.DemonstrationVideoLink.IsNotNullOrEmpty())
161 {
162 <div class="p p-video p-width-auto col-12 col-sm-12 col-md-6">
163 <div class="row">
164 <div class="p-video-container mb-1 col-12 order-first">
165 <div class="embed-responsive embed-responsive-16by9">
166 <iframe class="embed-responsive-item" src="@espressoProduct.DemonstrationVideoLink" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen="" width="1080" height="608" frameborder="0"></iframe>
167 </div>
168 </div>
169 </div>
170 </div>
171 }
172 </div>
173 </div>
174 </section>
175 }
176
177 <!-- ProductReviews -->
178 @if (espressoProduct.ProductReviews.IsNotNullOrEmpty())
179 {
180 <section class="e-section pb-2">
181 <div class="container-fluid">
182 <div class="row">
183 <div class="col-12">
184 <p class="h2">@Translate("Product - Review and References - Heading", "Omtale og referencer")</p>
185 </div>
186 </div>
187 <div class="row">
188 <div class="col-12">
189 @espressoProduct.ProductReviews
190 </div>
191 </div>
192 </div>
193 </section>
194 }
195
196 <section class="e-section pb-2" id="catalogues">
197 <div class="container-fluid">
198 <div class="row">
199 <div class="col-12">
200 @if ( espressoProduct.PdfList.Count > 1 )
201 {
202 <p class="h2">@Translate( "Product - PDF - Heading - Plural", "Se produktkatalogerne" )</p>
203 }
204 else
205 {
206 <p class="h2">@Translate( "Product - PDF - Heading", "Se produktkataloget" )</p>
207 }
208 </div>
209 </div>
210 <div class="row">
211 <div class="col-12">
212 @foreach ( string pdfPath in espressoProduct.PdfList )
213 {
214 string pdfTitle = pdfPath.Split( '/' ).Last();
215 // TODO: Det er her dælme grimt, kan det gøres bedre? -->
216 string pdfTitlePretty = pdfTitle.Replace( "_", " " ).Replace( ".pdf", "" );
217
218 <p>
219 <img alt="pdf" src="/Files/Templates/Designs/duroc/_assets/img/icon-pdf.svg" style="width: 50px;"> <a href="@pdfPath" title="@pdfTitle">@pdfTitlePretty</a>
220 </p>
221 }
222 </div>
223 </div>
224 </div>
225 </section>
226
227 @if (espressoProduct.ReasonsToBuyPageId > 0)
228 {
229 <section class="e-section pb-2">
230 <div class="container-fluid">
231 <div class="row">
232 @RenderPageContent(espressoProduct.ReasonsToBuyPageId)
233 </div>
234 </div>
235 </section>
236 }
237 @if (espressoProduct.CasesPageId > 0)
238 {
239 <section class="e-section pb-2">
240 <div class="container-fluid">
241 <div class="row">
242 @RenderPageContent(espressoProduct.CasesPageId)
243 </div>
244 </div>
245 </section>
246 }
247
248 @if (espressoProduct.RelatedGroups.ContainsKey("RELGRP1"))
249 {
250 <section class="e-section pb-2">
251 <div class="container-fluid">
252 <div class="row">
253 <div class="col-12">
254 <div class="e-productlist-header">
255 <p class="h2">@Translate("Product - Variants - Heading", "Varianter og specifikationer")</p>
256 </div>
257 <div class="e-productlist-main">
258 @if (espressoProduct.RelatedGroups["RELGRP1"].Products != null && espressoProduct.RelatedGroups["RELGRP1"].Products.Any())
259 {
260 <table class="table table-responsive-lg table-striped">
261 <thead>
262 <tr>
263 <th>
264 @Translate("Filter_Facet_Label_Machine", "Maskine")
265 </th>
266 <th>
267 @Translate("Filter_Facet_Label_Chuck", "Chuck")
268 </th>
269 <th>
270 @Translate("Filter_Facet_Label_Stangkapacitet", "Stangkapacitet")
271 </th>
272 <th>
273 @Translate("Filter_Facet_Label_Spindelhastighed", "Spindelhastighed")
274 </th>
275 <th>
276 @Translate("Filter_Facet_Label_Maks. drejediameter", "Maks. drejediameter")
277 </th>
278 <th>
279 @Translate("Filter_Facet_Label_Maks. drejelængde", "Maks. drejelængde")
280 </th>
281 <th>
282 @Translate("Filter_Facet_Label_Særlige egenskaber", "Særlige egenskaber")
283 </th>
284 </tr>
285 </thead>
286
287 <tbody>
288 @foreach (DurocProduct product in espressoProduct.RelatedGroups["RELGRP1"].Products)
289 {
290 <tr>
291 <td>
292 @( product.Name.IsNotNullOrEmpty() ? product.Brand + " " + product.Name : "-")
293 </td>
294 <td>
295 @(product.ChuckSize.IsNotNullOrEmpty() ? product.ChuckSize : "-")
296 </td>
297 <td>
298 @(product.BarWorkingDiameter.IsNotNullOrEmpty() ? product.BarWorkingDiameter : "-")
299 </td>
300 <td>
301 @(product.SpindleSpeed.IsNotNullOrEmpty() ? product.SpindleSpeed : "-")
302 </td>
303 <td>
304 @(product.TurningDiameter.IsNotNullOrEmpty() ? product.TurningDiameter : "-")
305 </td>
306 <td>
307 @(product.TurningLength.IsNotNullOrEmpty() ? product.TurningLength : "-")
308 </td>
309 <td>
310 @(product.SpecialFeatures.IsNotNullOrEmpty() ? product.SpecialFeatures : "-")
311 </td>
312 </tr>
313 }
314 </tbody>
315 </table>
316 }
317 </div>
318 </div>
319 </div>
320 </div>
321 </section>
322 }
323 <section class="e-section">
324 <div class="container-fluid">
325 <div class="row">
326 @{
327 int serviceaftalerParagraphId = default(int);
328 string serviceaftalerParagraphIdToString = PageView.Current().Area.Item["EcommerceServiceaftaler"]?.ToString();
329
330 int leasingParagraphId = default(int);
331 string leasingParagraphIdToString = PageView.Current().Area.Item["EcommerceLeasing"]?.ToString();
332
333 int educationParagraphId = default(int);
334 string educationParagraphIdToString = PageView.Current().Area.Item["EcommerceEducation"]?.ToString();
335
336 int informationParagraphId = default(int);
337 string informationParagraphIdToString = PageView.Current().Area.Item["EcommerceInformation"]?.ToString();
338 }
339
340 @if (int.TryParse(serviceaftalerParagraphIdToString, out serviceaftalerParagraphId))
341 {
342 @RenderPageContent(serviceaftalerParagraphId)
343
344 }
345 @if (int.TryParse(leasingParagraphIdToString, out leasingParagraphId))
346 {
347 @RenderPageContent(leasingParagraphId)
348 }
349 @if (int.TryParse(educationParagraphIdToString, out educationParagraphId))
350 {
351 @RenderPageContent(educationParagraphId)
352 }
353 @if (int.TryParse(informationParagraphIdToString, out informationParagraphId))
354 {
355 @RenderPageContent(informationParagraphId)
356 }
357 @if (espressoProduct.ContactPersonId > 0)
358 {
359 if (espressoProduct.ContactPersonAnchorId.IsNotNullOrEmpty())
360 {
361 <span id="@espressoProduct.ContactPersonAnchorId"></span>
362 }
363 <div class="js-render-page-content" data-page-id="@espressoProduct.ContactPersonId">
364 <div class=" position-relative pb-1 pt-6">
365 @RenderingService.Instance.PartialView( "_partials/loading-spinner.cshtml" )
366 </div>
367 </div>
368 }
369 </div>
370 </div>
371 </section>
372
373
374 @RenderingService.Instance.PartialView( "ecom/product/partials/metadata.cshtml", espressoProduct )
375 @RenderingService.Instance.PartialView( "ecom/product/partials/gtm-tracking.cshtml", espressoProduct )
376
377 <code class="js-e-breadcrumb-item-append" data-text="@HttpUtility.HtmlAttributeEncode( espressoProduct.Name )" data-link="@HttpUtility.HtmlAttributeEncode( espressoProduct.Link )"></code>
378
379 <script>
380 e4.data.set( '@espressoProduct.Id.Replace(" ", "")', JSON.parse('@HttpUtility.JavaScriptStringEncode( JsonService.Instance.ToJson( espressoProduct ) )') )
381 </script>
382
383 </div>
384 @RenderingService.Instance.SectionStart( new SectionSettings() )
385