Varukorg
Rental
Inga produkter valda

Din orderlista är tom

Error executing template "Designs/SkanskaMaskin/eCom7/CartV2/Step/varukorg.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at Softgear.Skanskamaskin.Analytics.ProductData.CreateCheckoutStepData() in C:\TFS\Skanskamaskin\Main\Softgear.SkanskaMaskin.Analytics\ProductData.cs:line 21
   at Softgear.Skanskamaskin.Analytics.AnalyticsRenderer.RenderCartCheckoutSteps(String eventName) in C:\TFS\Skanskamaskin\Main\Softgear.SkanskaMaskin.Analytics\AnalyticsRenderer.cs:line 66
   at CompiledRazorTemplates.Dynamic.RazorEngine_42c668a2a064406a8c0117d6ef9bff8b.Execute() in D:\wwwroot\rental.skanska.se\Files\Templates\Designs\SkanskaMaskin\eCom7\CartV2\Step\varukorg.cshtml:line 326
   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 RazorTemplateBase<RazorTemplateModel<Template>> 2 @using Dynamicweb.Rendering; 3 @using Softgear.SkanskaMaskin.Data.Business 4 @using Softgear.SkanskaMaskin.Data.Entities.Cart 5 @using Softgear.SkanskaMaskin.Data.Entities.Common 6 @using Softgear.SkanskaMaskin.IbxRoundtrip 7 @using Attribute = Softgear.SkanskaMaskin.Data.Entities.Common.Attribute 8 @using System.Web 9 @using Dynamicweb.Security.UserManagement 10 @using Softgear.Skanskamaskin.Analytics; 11 @inherits RazorTemplateBase<RazorTemplateModel<Template>> 12 @using Dynamicweb.Rendering 13 @using Softgear.SkanskaMaskin.Data.Entities.Cart 14 @using Softgear.SkanskaMaskin.Data.Entities.Common 15 @using Softgear.SkanskaMaskin.Data.Entities.Product 16 @functions{ 17 18 public List<Orderline> GetProductListFromOrderLineLoop(List<string> getAccessoryGroups = null) 19 { 20 21 var orderlines = new List<Orderline>(); 22 var inputs = new List<Input>(); 23 var accessoryProducts = new List<Product>(); 24 var product = new Product(); 25 26 foreach (var orderLine in GetLoop("OrderLines")) 27 { 28 product = new Product(); 29 inputs = new List<Input>(); 30 accessoryProducts = new List<Product>(); 31 var inputMessage = ""; 32 33 if (getAccessoryGroups != null) 34 { 35 // accessoryProducts = GetAccessoryProducts(orderLine.GetLoop("ProductRelatedGroups"), getAccessoryGroups); 36 } 37 38 inputs.Add(new Input() { name = "Key", value = orderLine.GetString("Ecom:Order:orderLine.Id") }); 39 40 var productImage = new Image 41 { 42 src = orderLine.GetString("Ecom:Product.ImageLarge.Clean"), 43 link = new Link() 44 }; 45 46 /*TODO: Make dynamic*/ 47 var productPrice = new Price 48 { 49 unit = "kr", 50 period = "dag", 51 text = "Beräknad på", 52 input = new PriceInput(), 53 active = 54 { 55 key = "0", 56 interval = "1 vecka", 57 price = "420", 58 text = "1 vecka á 420 kr/dag" 59 }, 60 range = 61 { 62 new PriceRange() {key = "0", interval = "1 vecka", price = "420", text = "<b>1 vecka</b> á 420 kr/dag"}, 63 new PriceRange() {key = "1", interval = "2 vecka", price = "400", text = "<b>2 veckor</b> á 400 kr/dag"} 64 } 65 }; 66 67 product.id = orderLine.GetString("Ecom:Order:OrderLine.ProductID"); 68 product.tag = orderLine.GetString("Ecom:Order:OrderLine.ProductNumber"); 69 product.heading = orderLine.GetString("Ecom:Order:OrderLine.ProductName"); 70 product.sub = ""; 71 product.description = ""; 72 product.image = productImage; 73 product.price = productPrice; 74 product.accessories = accessoryProducts; 75 product.notices = new List<Notice>() 76 { 77 new Notice() {isExpanded = true, heading = "Ingår alltid", text = "2st batterier, Laddare i transportlåda."}, 78 new Notice() 79 { 80 isExpanded = true, 81 heading = "Rekommenderade säkerhetsprodukter", 82 items = 83 { 84 new NoticeItem() {icon = "glasses", href = "/sakerhetsprodukter/#glasses", text = "Skyddsglasögon"}, 85 new NoticeItem() {icon = "ears", href = "/sakerhetsprodukter/#ears", text = "Hörselskydd"}, 86 new NoticeItem() {icon = "shoes", href = "/sakerhetsprodukter/#shoes", text = "Stövlar"}, 87 new NoticeItem() {icon = "gloves", href = "/sakerhetsprodukter/#gloves", text = "Skyddshandskar"} 88 } 89 } 90 }; 91 92 foreach (var fi in orderLine.GetLoop("Order.OrderLineFields")) 93 { 94 if (fi.GetString("Ecom:Order:OrderLine.OrderLineField.SystemName") == "Meddelande") 95 { 96 inputMessage = fi.GetString("Ecom:Order:OrderLine.OrderLineField.Value.Clean"); 97 } 98 } 99 100 101 orderlines.Add(new Orderline() 102 { 103 product = product, 104 count = Convert.ToInt16(orderLine.GetString("Ecom:Order:OrderLine.Quantity")), 105 accessories = accessoryProducts, 106 actions = new CartFormActions 107 { 108 count = new Input 109 { 110 name = string.Format("QuantityOrderLine{0}", orderLine.GetValue("Ecom:Order:orderLine.Id")), 111 value = Convert.ToString(orderLine.GetValue("Ecom:Order:OrderLine.Quantity")) 112 } 113 }, 114 inputs = inputs, 115 messageName = string.Format("OrderLineFieldValue_{0}_Meddelande", orderLine.GetValue("Ecom:Order:orderLine.Id")), 116 message = inputMessage 117 }); 118 } 119 120 return orderlines; 121 } 122 /* 123 private List<Product> GetAccessoryProducts(object relatedProductLoops, List<string> getAccessoryGroups = null) 124 { 125 var accessoryProducts = new List<Product>(); 126 if (getAccessoryGroups != null) { 127 foreach (var relatedGroups in relatedProductLoops.GetLoop("ProductRelatedGroups")) 128 { 129 var relatedGroupName = relatedGroups.GetString("Ecom:Product:RelatedGroup.Name"); 130 if (getAccessoryGroups.Contains(relatedGroupName)) 131 { 132 foreach (RazorTemplateBase<>.LoopItem prods in relatedGroups.GetLoop("Products")) 133 { 134 135 var productImage = new Image 136 { 137 Src = prods.GetString("Ecom:Product.ImageLarge.Clean"), 138 Link = new Link() 139 }; 140 141 var accessoryProduct = new Product 142 { 143 Id = prods.GetString("Ecom:Order:OrderLine.ProductID"), 144 Tag = prods.GetString("Ecom:Order:OrderLine.ProductNumber"), 145 Heading = prods.GetString("Ecom:Order:OrderLine.ProductName"), 146 Image = productImage, 147 Price = 148 { 149 IsSmall = true, 150 RangePos = "Right", 151 Unit = "kr", 152 Period = "dag", 153 Text = "Beräknad på", 154 Input = new PriceInput(), 155 Active = 156 { 157 Key = "0", 158 Interval = "1 vecka", 159 Price = "420", 160 Text = "1 vecka á 28kr/dag" 161 }, 162 Range = 163 { 164 new PriceRange(){ Key = "0", Interval = "1 vecka", Price = "420", Text = "<b>1 vecka</b> á 420 kr/dag" }, 165 new PriceRange(){ Key = "1", Interval = "2 vecka", Price = "400", Text = "<b>2 veckor</b> á 400 kr/dag" } 166 } 167 }, 168 }; 169 170 accessoryProducts.Add(accessoryProduct); 171 } 172 } 173 } 174 } 175 return accessoryProducts; 176 } 177 */ 178 179 180 } 181 182 183 184 185 186 187 188 189 @{ 190 var currentRoundtrip = new IbxRoundtrip(); 191 192 193 194 var loggedIn = User.IsExtranetUserLoggedIn(); 195 var hookUrl = HttpContext.Current.Request["HOOK_URL"]; 196 if (string.IsNullOrEmpty(hookUrl) == false) 197 { 198 currentRoundtrip.HookUrl = hookUrl; 199 } 200 201 202 var sendToIbx = HttpContext.Current.Request["sendToIbx"]; 203 if (IbxRoundtrip.IsIbxOrder() && string.IsNullOrEmpty(sendToIbx) == false) 204 { 205 currentRoundtrip.ProcessOrder(); 206 } 207 208 var hbh = new HandleBarsHelper(); 209 var jr = new JsonRenderer(); 210 var loginText = ""; 211 212 if (!loggedIn) 213 { 214 loginText = "Är du redan kund? <a href=\"/form/login\" class=\"js-overlayTrigger\">Logga in här</a> för att göra en beställning till ett projekt och se din rabatt."; 215 } 216 217 var cart = new Cart() 218 { 219 heading = Translate("Inkopslista_heading", "Orderlista"), 220 count = GetInteger("Ecom:Order.OrderLines.TotalQuantity"), 221 price = GetInteger("Ecom:Order.OrderLines.Total.Price"), 222 unit = "kr", 223 period = "byggdag", 224 text = new CartText() 225 { 226 accessory = "Ingår utan extra kostnad", 227 empty = "Din orderlista är tom.<br/> Lägg till <a href='/produkter'>produkter</a> för att skapa en orderlista." 228 }, 229 nav = new Nav() 230 { 231 items = new List<NavItem>() 232 { 233 new NavItem() 234 { 235 text = Translate("Inkopslista_Dela_listan", "Dela listan"), 236 href = "/form/sharelist", 237 attrs = new List<Attribute>() 238 { 239 new Attribute { prop = "class", val = "js-overlayTrigger" }, 240 new Attribute { prop = "data-controller", val = "overlay" } 241 } 242 }, 243 new NavItem() 244 { 245 text = Translate("Inkopslista_Skrivut", "Skriv ut"), 246 attrs = new List<Attribute>() 247 { 248 new Attribute { prop = "data-controller", val = "print" }, 249 } 250 }, 251 new NavItem() 252 { 253 text = "Ladda ner Excelfil", 254 href = "/webservice/ExcelService.svc/GetOrderExcel" 255 } 256 } 257 }, 258 back = new Link() 259 { 260 text = "Tillbaka", 261 active = true, 262 href = "/produkter" 263 }, 264 submit = new NavItem() 265 { 266 text = loggedIn ? "Välj leveranssätt" : "Skicka orderförfrågan", 267 href = loggedIn ? "/form/choosedelivery" : "/form/order", 268 attrs = new List<Attribute>() 269 { 270 new Attribute() { prop = "class", val = "Button js-overlayTrigger"}, 271 new Attribute() { prop = "data-controller", val = "overlay"}, 272 273 } 274 }, 275 loginprompt = loginText, 276 products = jr.renderProductList(WebHelper.getProductsFromCart(this)), 277 form = new CartForm() 278 { 279 method = "post", 280 action = "/cart/", 281 actions = new CartFormActions() 282 { 283 trash = new Input() { name = "cartcmd", value = "DelOrderLine" }, 284 count = new Input() { name = "count" } 285 }, 286 inputs = new List<Input>() 287 { 288 new Input() { name = "productid", value= "" }, 289 new Input() { name = "cartcmd", value= "update" }, 290 new Input() { name = "redirect", value= "/default.aspx?id=20" } 291 }, 292 message = new CartMessages 293 { 294 general = new Input 295 { 296 placeholder = "Skriv ett generellt meddelande...", 297 name = "message" 298 }, 299 item = new Input 300 { 301 text = "Lägg till önskemål / aktivitet", 302 placeholder = "Skriv ett meddelande..." 303 } 304 , 305 rentalTime = new Input 306 { 307 text = "Önskad hyrtid", 308 placeholder = "Ange önskad hyrtid..." 309 } 310 } 311 } 312 }; 313 if (IbxRoundtrip.IsIbxOrder()) 314 { 315 cart.submit.text = "Tillbaka till IBX."; 316 cart.submit.href = "/varukorg?sendToIbx=true"; 317 } 318 319 320 var partialPathList = new List<string> { "cart/items.hbs" }; 321 hbh.registerHelper("json", WebHelper.serializeToJson(cart)); 322 @hbh.render("cart/index.hbs", partialPathList, cart); 323 } 324 325 <script type="text/javascript"> 326 @AnalyticsRenderer.RenderCartCheckoutSteps("begin_checkout") 327 </script>
forEach