Exception in template (Designs\RizzoDesignFolder\eCom/Product/Teacher.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.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
   at System.Convert.ToInt32(String value)
   at CompiledRazorTemplates.Dynamic.daaddbccecc.Execute()
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context)
   at RazorEngine.Templating.TemplateService.Run(ITemplate template, DynamicViewBag viewBag)
   at RazorEngine.Templating.TemplateService.Parse(String razorTemplate, Object model, DynamicViewBag viewBag, String cacheName)
   at RazorEngine.Razor.Parse[T](String razorTemplate, T model, String cacheName)
   at Dynamicweb.Rendering.Template.Output()
@inherits RazorTemplateBase<RazorTemplateModel<Template>> @using Dynamicweb.Rendering; @using Dynamicweb.eCommerce.Products; @using Dynamicweb.Extensibility.Provider; @using System; @using System.IO; @using System.Web; @using System.Text; @using System.Collections.Generic; @using System.Text.RegularExpressions; @using System.Globalization; @{ string designName = GetString("Template:DesignBaseUrl").Replace("/Files/Templates/Designs/", "").Replace("/", ""); }@functions{ public static string GetImage(string sourceString, int imageWidth, int imageHeight, int imageWidthTablet = 0, int imageHeightTablet = 0, int imageWidthMobile = 0, int imageHeightMobile = 0, string imageFormat = "jpg", int imageCompression = 0, int imageCrop = 5, string background = "", string designName = "RizzoDesignFolder") { Dynamicweb.Frontend.PageView currentPageview = Dynamicweb.Frontend.PageView.Current(); string currDevice = currentPageview.Device.ToString(), alternativeImage = currentPageview.Area.Item["NoImage"] != null ? currentPageview.Area.Item["NoImage"].ToString() : "/Files/Templates/Designs/"+ designName + "/images/alternativeImage.jpg", widthString = "", heightString = "", getImageFormat = imageFormat != "jpg" ? "&amp;Format=" + imageFormat : "", getImageCompression = imageCompression != 0 ? "&amp;Compression=" + imageCompression : "", bgColor = !string.IsNullOrEmpty(background) ? "&amp;backgroud="+background : ""; int getImageWidth = imageWidth != 0 ? imageWidth : 0, getImageHeight = imageHeight != 0 ? imageHeight : 0; if (currDevice == Dynamicweb.Frontend.PageView.DeviceType.Tablet.ToString()) { getImageWidth = imageWidthTablet != 0 ? imageWidthTablet : getImageWidth; getImageHeight = imageHeightTablet != 0 ? imageHeightTablet : getImageHeight; } else if (currDevice == Dynamicweb.Frontend.PageView.DeviceType.Mobile.ToString()) { getImageWidth = imageWidthMobile != 0 ? imageWidthMobile : getImageWidth; getImageHeight = imageHeightMobile != 0 ? imageHeightMobile : getImageHeight; } if (getImageWidth != 0) { widthString = "&amp;Width=" + getImageWidth; } if (getImageHeight != 0) { heightString = "&amp;Height=" + getImageHeight; } string output = "/Admin/Public/GetImage.ashx?Image=" + sourceString + widthString + heightString + "&amp;altFmImage_path=" + alternativeImage + getImageFormat + getImageCompression + "&amp;Crop=" + imageCrop + bgColor; return output; } } @inherits RazorTemplateBase<RazorTemplateModel<Template>> @using Dynamicweb.Rendering; @functions{ private string GetImagePathUrl(string small, string medium, string large, string pattern) { string imagePath; if (!string.IsNullOrEmpty(small)) imagePath = small; else if (!string.IsNullOrEmpty(medium)) imagePath = medium; else if (!string.IsNullOrEmpty(large)) imagePath = large; else imagePath = pattern; return imagePath; } } @{ Dynamicweb.Content.Items.Item areaItem = Pageview.Area.Item; bool isLoggedIn = Pageview.User.LoggedIn, isFrontEnd = Dynamicweb.ExecutingContext.IsFrontEnd(), productIsFavorite = GetBoolean("Ecom:Product.IsProductInFavoriteList"); string currentPageId = Pageview.Page.ID.ToString(), variantDefaultId = GetString("Ecom:Product.DefaultVariantComboID"), variantCurrentId = GetString("Ecom:Product.VariantID"), variantId = (!string.IsNullOrEmpty(variantCurrentId)) ? variantCurrentId : variantDefaultId, titleKey = "title", title = "", imageKey = "image", image = "", stockStatus = GetInteger("Ecom:Product.Stock") > 0 ? "fa-check" : "fa-close", productId = GetString("Ecom:Product.ID"), productLanguage = GetString("Ecom:Product.LanguageID"), productName = GetString("Ecom:Product.Name"), productNumber = GetString("Ecom:Product.Number"), pattern = productNumber + "*", productImage = GetImagePathUrl(GetString("Ecom:Product.ImageSmall.Clean"), GetString("Ecom:Product.ImageMedium.Clean"), GetString("Ecom:Product.ImageLarge.Clean"), pattern), productGetImage = GetImage(productImage, 0, 600), imagesFolder = "/Files/Files/"+designName+"/Products/", imagePattern = imagesFolder + productNumber + ".jpg", productIntro = GetString("Ecom:Product.ShortDescription"), productDescription = GetString("Ecom:Product.LongDescription"), pointPrice = GetString("Ecom:Product.PointPrice"), productDetails = GetString("Ecom:Product:Field.Details.Value.Clean"), productWarranty = GetString("Ecom:Product:Field.Warranty.Value.Clean"), productPrice = GetString("Ecom:Product.Price"), productRemoveFromList = "/Default.aspx?Id="+currentPageId+ "&amp;ProductID=" + productId +"&amp;CCRemoveFromMyLists="+productId+"&amp;CCRemoveFromListVariantID="+variantId+"&amp;CCRemoveFromListLanguageID="+productLanguage, productAddToList = "/Default.aspx?Id="+currentPageId+ "&amp;ProductID=" + productId +"&amp;CCAddToMyLists="+productId+"&amp;CCAddToListVariantID="+variantId+"&amp;CCAddToListLanguageID="+productLanguage, favoriteUrl = productIsFavorite ? productRemoveFromList : productAddToList, // Filter for downloads item downloadsFilter = "Products contains 'p_"+productId+",' or Products contains 'p_"+productId+":' or Products ends with 'p_"+productId+"'"; List<Dictionary<string, string>> imagesList = new List<Dictionary<string, string>>(); } <div id="product-container" class="teacher-container" data-pageId="@currentPageId" data-productId="@productId" data-variantId="@variantId" data-errorCombination1='@Translate("combinationNotAvailable","Combination not available")' > <article id="product-description" class="col-xs-12 noPadding"> <div id="leftSide" class="col-xs-12 col-lg-8"> <div> <div class="smartbuttons"> <a href="javascript:window.print();" id="smart_print"></a> </div> @if (!String.IsNullOrEmpty(productImage)) { <div id="product-image"> <figure> <img class="img-responsive" src="@productGetImage" alt="@productName" title="@productName" /> </figure> </div> } <h2>@productName</h2> @if (!String.IsNullOrEmpty(productIntro) || !String.IsNullOrEmpty(productDescription)) { <div id="product-description"> @productIntro @productDescription </div> } </div> </div> <div id="rightSide" class="col-xs-12 col-lg-4"> <div> @{ string sql = string.Format("SELECT * FROM EcomProducts p INNER JOIN EcomProductsRelated pr ON pr.ProductRelatedProductID = p.ProductID WHERE pr.ProductRelatedProductRelID = '{0}' and p.ProductLanguageID ='{1}' and pr.ProductRelatedGroupID = 'RELGRP2'", productId, productLanguage); var relatedProducts = Dynamicweb.eCommerce.Products.Product.GetProductsBySql(sql); if (relatedProducts.Any()) { int relatedProductsIndex = 0; int productMonth = 0; int productYear = 0; int productDay = 0; <div class="related-products-legend hidden-lg">@Translate("UnderviserPafolgende", "Underviser på følgende kurser/netværk")</div> <div class="related-products-legend-rev hidden-md hidden-sm hidden-xs">@Translate("UnderviserPafolgende", "Underviser på følgende kurser/netværk")</div> @*<div class="BoxBelow"></div>*@ <ul class="related-products"> @foreach (var relatedProduct in relatedProducts) { relatedProductsIndex++; var relatedProductDay = relatedProduct.ProductFieldValues.GetProductFieldValue("Day"); var relatedProductMonth = relatedProduct.ProductFieldValues.GetProductFieldValue("Month"); var relatedProductYear = relatedProduct.ProductFieldValues.GetProductFieldValue("Year"); string ShowDateOnList = relatedProduct.ProductFieldValues.GetProductFieldValue("ShowDateOnList").Value.ToString(); var relatedProductLectures = relatedProduct.ProductFieldValues.GetProductFieldValue("Lectures"); string relatedProductLecturesDecimal = relatedProduct.ProductFieldValues.GetProductFieldValue("LecturesDecimal").Value.ToString(); DateTime currentDate = DateTime.Now; string[] monthNames = DateTimeFormatInfo.CurrentInfo.AbbreviatedMonthNames; string relatedProductID = relatedProduct.ID, relatedProductName = relatedProduct.Name, relatedProductIntro = relatedProduct.ShortDescription, relatedProductText = Dynamicweb.Base.TeaserString(StripHtml(relatedProductIntro), 80, "..."), relatedProductDate = string.Format("<strong>{0}</strong><span>{1}</span>", relatedProductDay.Value.ToString(), monthNames[Convert.ToInt32(relatedProductMonth.Value.ToString()) - 1]), relatedProductLink = "javascript:void(0)", relatedProductPrimaryGroupID = relatedProduct.PrimaryGroupID, relatedProductMod2Class = "mod"+(relatedProductsIndex % 2).ToString(), relatedProductClass = "related-product-item " + relatedProductMod2Class; //Hide related products if outdated productDay = Convert.ToInt32(relatedProductDay.Value.ToString()); productMonth = Convert.ToInt32(relatedProductMonth.Value.ToString()); productYear = Convert.ToInt32(relatedProductYear.Value.ToString()); bool productIsActive = isActive(productMonth, productYear, productDay); var relatedProductGroups = relatedProduct.Groups; if (relatedProductGroups.Any()) { var relatedProductGroup = (!String.IsNullOrEmpty(relatedProductPrimaryGroupID)) ? relatedProductGroups.Where(x => x.ID == relatedProductPrimaryGroupID).First() : relatedProductGroups.First(); if (!relatedProductGroup.IsTopGroup) { string relatedProductGroupPrimaryParentGroupID = relatedProductGroup.PrimaryParentGroupID; if (relatedProductGroup.ParentGroups.Any()) { relatedProductGroup = (!String.IsNullOrEmpty(relatedProductGroupPrimaryParentGroupID)) ? relatedProductGroup.ParentGroups.Where(x => x.ID == relatedProductGroupPrimaryParentGroupID).First() : relatedProductGroup.ParentGroups.First(); } } string relatedProductGroupPrimaryPage = relatedProductGroup.Meta.PrimaryPage.ToString(), relatedProductGroupColor = relatedProductGroup.ProductGroupFieldValues.GetProductGroupFieldValue("Color").Value.ToString(); if (!String.IsNullOrEmpty(relatedProductGroupPrimaryPage)) { relatedProductLink = relatedProductGroupPrimaryPage + "&productid=" + relatedProductID; } if (!String.IsNullOrEmpty(relatedProductGroupColor)) { relatedProductClass += " " + relatedProductGroupColor; } } <li class="@relatedProductClass @(productIsActive ? "" : "hide")"> <div> <div class="related-info"> <ul> <li class="productDate "> <div> @if(ShowDateOnList == "False"){ @relatedProductDate } </div> </li> <li class="productLessons"> <div> <strong> @if ( !String.IsNullOrEmpty(relatedProductLecturesDecimal) && (relatedProductLecturesDecimal!="0") ) { @relatedProductLecturesDecimal } else{ @relatedProductLectures.Value } </strong> <span>@Translate("ShortLectures", "Lekt.")</span> </div> </li> </ul> </div> <div class="related-details"> <h3> <a href="@relatedProductLink" title="@relatedProductName"> @relatedProductName </a> </h3> @*<div> <a href="@relatedProductLink" title="@relatedProductName"> @relatedProductText </a> </div>*@ </div> </div> <a href="@relatedProductLink" title="@relatedProductName" class="overlayLink">@relatedProductName</a> </li> } </ul> } } </div> </div> </article> </div> @SnippetStart("OGMeta") <meta property="og:title" content='@productName' /> <meta property="og:image" content='@Pageview.GlobalTags.GetTagByName("Global:Request.Scheme").Value.ToString()://@Pageview.GlobalTags.GetTagByName("Global:Request.Host").Value.ToString()@imagePattern' /> <meta property="og:site_name" content='@areaItem["CompanyName"]' /> <meta property="og:url" content='@Pageview.GlobalTags.GetTagByName("Global:Request.Scheme").Value.ToString()://@Pageview.GlobalTags.GetTagByName("Global:Request.Host").Value.ToString()@Pageview.GlobalTags.GetTagByName("Global:Pageview.Url").Value.ToString()' /> <meta property="og:description" content="@StripHtml(productIntro)" /> <meta property="og:type" content="article" /> <meta property="og:locale" content='@Pageview.GlobalTags.GetTagByName("Global:Area.LongLang").Value.ToString().Replace("-", "_")' /> @SnippetEnd("OGMeta") @SnippetStart("jsOnLoad") @SnippetEnd("jsOnLoad") @functions { public static string StripHtml(string source) { return Regex.Replace(source, "<.*?>", string.Empty); } public bool isActive(int productMonth, int productYear, int productDay){ DateTime productDate = new DateTime(productYear,productMonth,productDay); DateTime localDate = DateTime.Now; int result = DateTime.Compare(productDate, localDate); if(result > 0){ return true; } else{ return false; } } }