public ActionResult CreateQuoteFromDrawing(BalustradeDrawingModel model) { var balustrade = CreateBalustradeFromDrawingModel(model); var line = new QuoteLine(); line.Name = balustrade.Name; line.Price = balustrade.SilverSellingPrice; line.BronzePrice = balustrade.BronzeSellingPrice; line.GoldPrice = balustrade.GoldSellingPrice; line.ProductDetails = balustrade; Session[SessionKeys.PENDING_QUOTE_LINE] = line; return(Json(new { })); }
public ActionResult AddDrawingToCart(BalustradeDrawingModel model) { var balustrade = CreateBalustradeFromDrawingModel(model); double price; if (model.CartType == BalustradeDrawingModelCartType.Full) { price = (balustrade.SellingPrice ?? 0D) * (1D - (balustrade.BalustradeSystem.OnlineDrawingDiscount / 100D)); balustrade.Locked = true; balustrade.OnlineDrawingApproved = true; } else { price = balustrade.SellingPrice ?? 0D; } DbSession.SaveOrUpdate(balustrade); AddToCart(balustrade, Math.Max(model.Quantity ?? 1, 1), price); DbSession.Flush(); return(Json(new { })); }
private Balustrade CreateBalustradeFromDrawingModel(BalustradeDrawingModel model) { var balustrade = new Balustrade { Color = DbSession.Get <ColorLocal>(model.ColorId), GlassSystem = DbSession.Get <GlassSystemLocal>(model.GlassId), BalustradeSystem = DbSession.Get <BalustradeSystemLocal>(model.SystemId) }; balustrade.UpdateSystemDefaults(); InitializeViews(balustrade); balustrade.StartType = model.StartType; balustrade.EndType = model.EndType; balustrade.AluminumSpacers = true; if (model.HRBR.HasValue && model.HRBR.Value > 0) { balustrade.HRBR = model.HRBR.Value; balustrade.HRBRC = true; } if (model.BRHR.HasValue && model.BRHR.Value > 0) { balustrade.BRHR = model.BRHR.Value; balustrade.BRHRC = true; } balustrade.DrawBlack = false; balustrade.CurrentViewIndex = model.ViewIndex % balustrade.BalustradeViews.Count; if (model.StartWallAngle.HasValue) { balustrade.WSA = model.StartWallAngle.Value; balustrade.WSAR = false; } if (model.EndWallAngle.HasValue) { balustrade.WEA = model.EndWallAngle.Value; balustrade.WEAR = false; } var i = 0; foreach (var section in model.Sections) { var balSection = new BalustradeSection { Balustrade = balustrade, Length = section.Length, Angle = section.Angle, Ofst = section.Ofst ?? 0, CalculatePostsQuantity = true, CalculateHandrailJoints = true, PreferStockGlass = balustrade.BalustradeSystem.PreferStockGlass }; if (i == 0 && model.WG.HasValue) { balSection.PreferStockGlass = false; balustrade.WG = model.WG.Value; } if (i == model.Sections.Count - 1 && model.GW.HasValue) { balSection.PreferStockGlass = false; balustrade.GW = model.GW.Value; } balustrade.RawBalustradeSections.Add(balSection); i += 1; } return(balustrade); }