Norsk Svensk
optura
  • List item 1
  • List item 2
  • List item 3
  • List item 4
DwPageName_1: Produkter
DwPageName_2:
Exception in template (eCom/Product/Optura2014_Product.cshtml): System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.ddddcccffdc.Execute()
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context)
   at RazorEngine.Razor.Parse[T](String razorTemplate, T model, String cacheName)
   at Dynamicweb.Rendering.Template.Output()
@using Optura_MinSide @using Dynamicweb.Modules.UserManagement @using Dynamicweb @using Dynamicweb.eCommerce.Products @using System.Collections.Generic @using System.IO @using System.Web @{ var groupsForProduct = new List<string>(); foreach(var group in GetLoop("ProductGroups")){ groupsForProduct.Add(group.GetString("Ecom:Group.ID")); } var showAllSizesGroupList = new List<string>(){"601","602","603","604","605","606","607","608"}; var curPageID = GetValue("Ecom:Search.Page.ID"); var id = GetString("Ecom:Product.ID"); var number = GetString("Ecom:Product.Number"); string modelno = GetString("Ecom:Product:Field.Model"); string idOrModel = id; //image var imgSrc=""; var thumbnailSrc = ""; var zoomImgHref=""; if(String.IsNullOrWhiteSpace(modelno)){ //imgSrc = "http://dc4.optura.t7d.no/kunder/optura/getpic.php?vnr=" + number + "&template=400px"; imgSrc = "/admin/public/Getimage.ashx?Image=/Files/Images/eCom/big/" + number + ".jpg&Height=400&format=jpg"; thumbnailSrc = "/admin/public/Getimage.ashx?Image=/Files/Images/eCom/big/" + number + ".jpg&Height=100&format=jpg"; zoomImgHref = "/admin/public/Getimage.ashx?Image=/Files/Images/eCom/big/" + number + ".jpg&Height=1200&format=jpg"; } else{ //imgSrc = "http://dc4.optura.t7d.no/kunder/optura/getpic.php?vnr=" + modelno + "&template=400px"; imgSrc = "/admin/public/Getimage.ashx?Image=/Files/Images/eCom/big/" + modelno + ".jpg&Height=400&format=jpg"; thumbnailSrc = "/admin/public/Getimage.ashx?Image=/Files/Images/eCom/big/" + modelno + ".jpg&Height=100&format=jpg"; zoomImgHref = "/admin/public/Getimage.ashx?Image=/Files/Images/eCom/big/" + modelno + ".jpg&Height=1200&format=jpg"; } var no_imgSrc = "/admin/public/getimage.ashx?Image=/Files/Templates/Designs/Optura 2014/images/noimage.png&amp;Height=316&amp;Width=211&amp;format=png"; var productName = GetString("Ecom:Product.Name"); var popupUrl = "http://dc4.optura.t7d.no/kunder/optura/optura_flashpic.php?vnr=" + number; List<Product> sameModelProducts = null; //Getting product variants if(!string.IsNullOrWhiteSpace(modelno)){ string sql = string.Format("SELECT * FROM EcomProducts WHERE Model = '{0}'", modelno); sameModelProducts = Product.GetProductsBySql(sql).OrderBy( p=>(string)p.GetProductFieldValue("ModelVariant")).ToList(); idOrModel = modelno; } int inStock_int; var inStockTmp = System.Web.HttpContext.Current.Session["stock_" + id]; if (inStockTmp != null) { inStock_int = Convert.ToInt32(inStockTmp.ToString()); } else { inStock_int = GetInteger("Ecom:Product.Stock"); } string stockState = ""; string stock_message = ""; string stock_message2 = ""; if(inStock_int < 1){ stockState = "outOfStock"; stock_message = Translate("Ikke på lager"); stock_message2 = GetString("Ecom:Product:Field.AvailableDate"); }else if(inStock_int < 16){ stockState = "fewInStock"; stock_message = Translate("Få på lager"); }else if(inStock_int > 15){ stockState = "inStock"; stock_message = Translate("mange på lager"); } var stockImageSrc = "/Files/Templates/Designs/Optura 2014/images/" + stockState + "16x16.png"; var prodBrand = GetString("Ecom:Product:Field.BrandName"); if(prodBrand.Length < 1){ prodBrand = "-ingen definert-"; } var productShortDescription = GetString("Ecom:Product.ShortDescription"); var productLongDescription = GetString("Ecom:Product.LongDescription"); var displayPrice = GetDouble("Ecom:Product.Price.Price"); var displayPrice_string = String.Format("{0:0.00}", displayPrice); var link = GetString("Ecom:Product.Link.Clean"); var manufacturer = GetString("Ecom:Manufacturer.Name"); var userLoggedin = false; string allowedGroups = ""; string productGroups = ""; if (!string.IsNullOrWhiteSpace(GetGlobalValue("Global:Extranet.UserName"))) { userLoggedin = true; allowedGroups = ""; } else { userLoggedin = false; } int count = 0; Helper helper = new Helper(); bool allowToBuy = false; string ParentGroupID = "ParentGroupID"; if(!string.IsNullOrWhiteSpace(GetGlobalValue("Global:Extranet.UserName"))){ ParentGroupID = helper.GetParentGroupID(id); var user = User.get_Current(PagePermissionLevels.Frontend); allowToBuy = helper.userDealer_ForGroupID(user, ParentGroupID); } var ManualPath = GetString("Ecom:Product:Field.ManualPath.Value"); var prod_availableDate = ""; try{ prod_availableDate = (string)HttpContext.Current.Session["availableDate_" + id]; } catch (Exception ex) { prod_availableDate = ""; } stock_message2 = prod_availableDate; //group leveringstid logic Dynamicweb.eCommerce.Products.Group firstGroup = Dynamicweb.eCommerce.Products.Group.GetGroupByID(GetString("Ecom:Product.PrimaryOrFirstGroupID")); string groupLeveringstidText = Base.ChkString(firstGroup.ProductGroupFieldValues.GetProductGroupFieldValue("Leveringstid").Value); string groupLeveringstidFarge=""; string colorLink=""; if(String.IsNullOrEmpty(groupLeveringstidText)){ }else{ groupLeveringstidFarge = Base.ChkString(firstGroup.ProductGroupFieldValues.GetProductGroupFieldValue("LeveringstidFarge").Value); colorLink = (String.IsNullOrEmpty(groupLeveringstidFarge)) ? "" : String.Format("/Files/Templates/Designs/Optura 2014/images/colors/colors16x16/{0}.jpg", groupLeveringstidFarge); stock_message = groupLeveringstidText; stockImageSrc = colorLink; } } <div class="row"> <div class="large-1 medium-4 small-3 columns"> <div id="gallery_01"> <div> <a href="#" class="elevatezoom-gallery active" data-update="" data-image="@zoomImgHref" data-zoom-image="@zoomImgHref"> <img src="@thumbnailSrc" width="356"> </a> </div> @{ try { const string path = "/Files/Images/eCom/big/"; string filepath = String.Format("~{0}", path); var serverpath = System.Web.HttpContext.Current.Server.MapPath(filepath); try { var fileList = System.IO.Directory.GetFiles(serverpath, String.Format("{0}_*.*", number)); if (fileList.Length > 0) { foreach (var f in fileList) { var filename = System.IO.Path.GetFileName(f); var image_path = String.Format("{0}{1}", path, filename); //<p>f:@f image_path:@image_path</p> //f: RETURNS C:\Dynamicweb\Sites\DW_TEST_Optura\Files\Images\eCom\big\1502303_1.jpg //image_path: RETURNS /Files/Images/eCom/big/1502303_1.jpg string img_large = string.Format("/admin/public/Getimage.ashx?Image={0}&Height=1200&format=jpg", image_path); string img_small = string.Format("/admin/public/Getimage.ashx?Image={0}&Height=100&format=jpg", image_path); string img_thumb = string.Format("/admin/public/Getimage.ashx?Image={0}&Height=100&format=jpg", image_path); <div> <a href="#" class="elevatezoom-gallery active" data-update="" data-image="@img_large" data-zoom-image="@img_large"> <img src="@img_thumb" width="100"> </a> </div> } } //var file = System.IO.Directory.GetFiles(serverpath, String.Format("{0}.*", number)).First(); /*var filename = System.IO.Path.GetFileName(file); var image_path = String.Format("{0}{1}", path, filename); <p>image_path:@image_path</p>*/ } catch (Exception exc) { <p>EXC: @exc.ToString()</p> } } catch (Exception ex2) { <p>EX2: @ex2.ToString()</p> } } </div> </div> <div class="large-4 medium-8 small-9 columns"> <div class="ProdImgWrapper_outside"> <div class="ProdImgWrapper"> <div class="prodImg_boundries"> <img id="elevatezoom_image" src='@imgSrc' data-zoom-image="@zoomImgHref" alt="@GetString("Ecom:Product.Name")" onerror="this.src='@no_imgSrc'" border="0" /> </div> </div> </div> </div> <div class="large-7 medium-12 small-12 columns"> <h1 class="title-text">@idOrModel</h1> @if(!string.IsNullOrEmpty(ManualPath)){ var href = ManualPath.Replace("/bruksanvisninger/","/Manualer/"); href = href.Replace("/Manualer/","/Files/Manualer/"); var path = href.Replace("/",@"\"); path = path.Replace(@"\Manualer\",@"C:\solutions\optura.localtest.me\Files\Manualer\"); var FileName = Path.GetFileName(path); <a class="manual-link" href="@href" download="@FileName" ManualPath="@ManualPath"><img src="/Files/Templates/Designs/Optura 2014/images/pdf.png" border="0" /> Bruksanvisning</a> } <table> <tbody> <tr> <td>@Translate("Modell"):</td> <td>@idOrModel</td> </tr> @{ if(GetLoop("Details").Any()){ <tr> <td>@Translate("Manualer"):</td> <td>@foreach (LoopItem i in GetLoop("Details")) { <a href="@i.GetString("Ecom:Product:Detail.Image.Clean")"> <i class="step fi-page-doc size-24"></i> </a> } </td> </tr> } } <tr> <td>@Translate("Varemerke"):</td> <td>@prodBrand</td> </tr> <tr> <td>@Translate("Beskrivelse"):</td> <td>@productName</td> </tr> @if (userLoggedin && allowToBuy == true) { <tr> <td>@Translate("Lager"):</td> <td> @if(!String.IsNullOrEmpty(stockImageSrc)){ <img style="width:16px;height:16px" src="@stockImageSrc" /> } @stock_message</td> </tr> } @if (stock_message2 != "" && userLoggedin ) { <tr> <td>@Translate("Leveringstid"):</td> <td>@stock_message2</td> </tr> } @if (userLoggedin && allowToBuy == true) { <tr> <td>@Translate("Salgspris (LCY)"):</td> <td>@GetString("Ecom:Product:Field.SalesPrice.Value")</td> </tr> } <tr> <td>@Translate("Veil. pris (LCY)"): </td> <td>@GetString("Ecom:Product:Field.MarketPrice.Value")</td> </tr> @if(userLoggedin && allowToBuy == true){ <tr> <td><strong>@Translate("Din pris"):</strong></td> <td><strong>@GetValue("Ecom:Product.Price.Price")</strong></td> </tr> } </tbody> </table> <div> @{ if (userLoggedin && allowToBuy == true){ if(sameModelProducts != null && sameModelProducts.Count > 0){ <div><span>@Translate("opt_prodlist_choose","Velg størrelse/lengde:")</span></div> <div class="size-container"> @foreach(Product p in sameModelProducts){ int iStock; var iStockTemp = System.Web.HttpContext.Current.Session["stock_" + p.ID]; if (iStockTemp != null) { iStock = Convert.ToInt32(iStockTemp.ToString()); } else { iStock = Convert.ToInt32(p.Stock); } var available = ""; try{ available = (string)HttpContext.Current.Session["availableDate_" + p.ID]; } catch (Exception ex) { available = ""; } if(iStock>0 || !String.IsNullOrWhiteSpace(available) || groupsForProduct.Any(showAllSizesGroupList.Contains)){ string size = (string)p.GetProductFieldValue("ModelVariant"); <div class="sizebox" data-prod-id="@p.ID" data-prod-size="@size" data-prod-stock="@iStock" style="">@size</div> } } </div> } <div class="purchase-container"> <a id="purchase-btn" href="#" onclick="$('#addSingleProduct').submit()" class="button right blockUIbutton"><i class="step fi-shopping-cart size-24"></i>&nbsp;&nbsp;&nbsp;&nbsp;@Translate("Legg i handlevogn")</a> <a href="javascript:addtocart('@id')" class="debug">AJAX Add to cart</a> <form action="/Handlevogn.aspx" method="post" id="addSingleProduct" style="width:100px;margin-bottom:0px;margin-right:30px;" class="right"> <input type="hidden" name="cartcmd" value="add" /> <input id="product-id-input" type="hidden" name="productid" value="@GetValue("Ecom:Product.ID")" /> <input type="number" itemRel="@id" class="Quantity" name="Quantity" value="1" style="height:62px;font-size:18px;text-align:center;" /> </form> </div> }else if(userLoggedin && allowToBuy == false){ <a href="#" class="button right">@Translate("Du har ikke desverre ikke mulighet til å kjøpe denne varen")</a> }else{ if (Pageview.Area.ID == 1) { <a href="/Default.aspx?id=36" class="button right">@Translate("Du må logge deg inn")</a> }else if(Pageview.Area.ID == 2){ <a href="/Default.aspx?id=195" class="button right">@Translate("Du må logge deg inn")</a> } } } </div> <div style="display:none;clear:both;"></div> </div> <div class="large-2 columns" style="display:none;"><img src="/Files/Templates/Designs/Optura 2014/images/BrangLogoLinks/1.jpg" border="0" alt="Seiko" /></div> </div> <div class="row detailTabs" style="display:none;"> <div class="large-12"> <div> <ul class="tabs" data-tab="" role="tablist"> <li class="tab-title active" role="presentational"><a href="#panel1-1" role="tab" tabindex="0" aria-selected="true" controls="panel1-1">Long Description</a></li> <li class="tab-title" role="presentational"><a href="#panel1-2" role="tab" tabindex="-1" aria-selected="false" controls="panel1-2">Short Description</a></li> <li class="tab-title" role="presentational"><a href="#panel1-3" role="tab" tabindex="-1" aria-selected="false" controls="panel1-3">Tab 3</a></li> <li class="tab-title" role="presentational"><a href="#panel1-4" role="tab" tabindex="-1" aria-selected="false" controls="panel1-4">Tab 4</a></li> </ul> <div class="tabs-content"> <section role="tabpanel" aria-hidden="false" class="content active" id="panel1-1" tabindex="-1"> <div tabindex="0" tab-index="0"> @productShortDescription </div> </section> <section role="tabpanel" aria-hidden="true" class="content" id="panel1-2" tabindex="-1"> <div tabindex="0" tab-index="0"> @productLongDescription </div> </section> <section role="tabpanel" aria-hidden="true" class="content" id="panel1-3" tabindex="-1"> <p tabindex="0" tab-index="0">This is the third panel of the basic tab example. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptates, in, sunt, dolorem corrupti officia earum veritatis numquam provident exercitationem non impedit laborum dolor at repellat deleniti. Vero nobis quas tempore.</p> </section> <section role="tabpanel" aria-hidden="true" class="content" id="panel1-4" tabindex="-1"> <p tabindex="0" tab-index="0">This is the fourth panel of the basic tab example. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eos, veritatis, a, nisi, repellat fugit animi consectetur voluptas eligendi et iure voluptatibus neque ullam asperiores quae laboriosam praesentium suscipit amet deserunt.</p> </section> </div> <p></p> </div> </div> </div> <div> @{ /* imgSrc = "/admin/public/Getimage.ashx?Image=/Files/Images/eCom/big/" + number + ".jpg&Height=400&format=jpg"; zoomImgHref = "/admin/public/Getimage.ashx?Image=/Files/Images/eCom/big/" + number + ".jpg&Height=1200&format=jpg"; <img id="elevatezoom_image" src='@imgSrc' data-zoom-image="@zoomImgHref" /> */ } </div> <div> </div> <input type="hidden" value="@prodBrand" class="addToBreadcrumb" /> <input type="hidden" value="@id" class="addToBreadcrumb" /> <div> <!-- --> </div> <script> var currentProductId = "@id"; var goodstock ="@Translate("t_prodlist_goodstock", "På lager")"; var poorstock ="@Translate("t_prodlist_poorstock", "1-15 stk. på lager")"; var nostock ="@Translate("t_prodlist_nostock", "Utsolgt")"; var variants = ""; $( document ).ready(function() { $('.sizebox').on('click',function(){ setActive($(this).attr('data-prod-id')); }); calculateStock(); }); function setActive(id){ var newActive = $('.sizebox[data-prod-id="'+id+'"]'); resetActive(); calculateStock(); if(newActive !== null && newActive !== undefined){ var id = newActive.attr('data-prod-id'); var stock = newActive.attr('data-prod-stock'); var size = newActive.attr('data-prod-size'); newActive.html('&#10004;'); newActive.removeClass('good-stock'); newActive.removeClass('low-stock'); newActive.removeClass('no-stock'); newActive.addClass('activeProduct'); $('#product-id-input').val(id); $('#purchase-btn').removeClass('disable'); } } function resetActive(){ $('#purchase-btn').addClass('disable'); $('.sizebox').each(function(){ var box = $(this); box.removeClass('good-stock'); box.removeClass('low-stock'); box.removeClass('no-stock'); box.html(box.attr('data-prod-size')); }); } function calculateStock(){ console.log("calc"); $('.sizebox').each(function(){ var self = $(this); var stock = self.attr('data-prod-stock'); if(stock>15){ self.addClass('good-stock'); self.attr('title', goodstock); }else if(stock>0){ self.addClass('low-stock'); self.attr('title', poorstock); }else{ self.addClass('no-stock'); self.attr('title', nostock); } }); } $('.disabled').click(function(e){ e.preventDefault(); }); </script> <style> .title-text{ float:left; } .manual-link{ float:right; } .purchase-container{ width:50%; float:right; } .size-container{ width:50%; float:left; } .sizebox{ width: 49.8px; display: inline; border: 1px solid; padding: 10px; float: left; text-align: center; vertical-align: middle; margin-right:5px; } .activeProduct{ background-color: white; } .good-stock{ background-color: lightgreen; } .low-stock{ background-color: orange; } .no-stock{ background-color: red; } </style>