private BalustradeQuoteModel GetModel(string id, int type, int color, int glass, string mes, int price) { var model = DbSession.QueryOver <BalustradeModel>().Where(bm => bm.Url == id).Cacheable().CacheMode(CacheMode.Normal).SingleOrDefault(); if (model == null) { return(null); } var t = DbSession.Get <BalustradeSystemLocal>(type); var c = t.Colors.FirstOrDefault(clr => clr.ID == color) ?? t.Colors.FirstOrDefault(); var g = t.GlassSystems.FirstOrDefault(gl => gl.ID == glass) ?? t.GlassSystems.FirstOrDefault(); var bal = new Balustrade { BalustradeSystem = t, Color = c, GlassSystem = g }; bal.UpdateSystemDefaults(); bal.StartType = BalustradeSection.SectionFinishType.Wall; bal.EndType = BalustradeSection.SectionFinishType.Wall; bal.ModelId = model.ID; var mesParts = (mes ?? "").Split(";".ToCharArray()) .Select(p => { int parsed; return(Int32.TryParse(p, out parsed) ? parsed : 0); }) .Where(p => 0 < p && p < 999999) .ToArray(); var angle = mesParts.Length > 1 ? 90D : 0D; var i = 0; foreach (var dim in mesParts) { bal.RawBalustradeSections.Add(new BalustradeSection { Balustrade = bal, Length = dim, Angle = angle, Depth = (i < model.Sections.Count && model.Sections[i].Curved) ? 10 : 0, CalculatePostsQuantity = true, CalculateHandrailJoints = true, PreferStockGlass = t.PreferStockGlass }); i++; angle -= 90; } var viewModel = new BalustradeQuoteModel(model, bal, price, DbSession.CurrentUser()); return(viewModel); }
public BalustradeQuoteModel(BalustradeModel model, Balustrade balustrade, int p = 0, User user = null) : this() { TypeId = balustrade.BalustradeSystem.ID; ColorId = balustrade.Color.ID; GlassId = balustrade.GlassSystem.ID; foreach (var section in model.Sections) { Dims.Add(new BalustradeQuoteDimension(section)); } for (var i = 0; i < balustrade.RawBalustradeSections.Count; i++) { Dims[i].Length = (int)balustrade.RawBalustradeSections[i].Length; //Dims[i].Depth = (int)balustrade.RawBalustradeSections[i].Depth; } P = p; if (p == 1) { Price = balustrade.SellingPrice ?? 0D; } else if (p == 2) { VATEnabled = true; Price = (balustrade.SellingPrice ?? 0D) * (1D + ((user?.DefaultCompany?.VatPercent ?? 0D) / 100D)); } ModelId = model.ID; ModelImage = model.Image; ModelUrl = model.Url; Title = TemplateService.GetText(model.Title, balustrade); Keywords = TemplateService.GetText(model.Keywords, balustrade); Description = TemplateService.GetText(model.Description, balustrade); H1 = TemplateService.GetText(model.H1, balustrade); Body = TemplateService.GetText(model.Body, balustrade); List <string> imageExist = new List <string>(); for (int counter = 0; counter < 100; counter++) { string Imgsrc; Imgsrc = string.Empty; Imgsrc = "/images/balustrades/thumb/b"; Imgsrc += TypeId + "/"; Imgsrc += ModelImage + "/"; if (counter == 0) { Imgsrc += ColorId + ".jpg"; } else { Imgsrc += ColorId + "_" + counter + ".jpg"; } if (System.IO.File.Exists(HttpContext.Current.Server.MapPath(Imgsrc))) { imageExist.Add(Imgsrc); } } thumbnailimages = imageExist; }
private static void InitializeViews(Balustrade balustrade) { var noHandrail = balustrade.BalustradeSystem.HandrailSystem.ID == ProfileSystem.NO_PROFILE_ID; balustrade.BalustradeViews.Clear(); balustrade.BalustradeViews.Add(new BalustradeView { Name = "Overview", DrawBaseVectors = true, DrawBaseVectorsAngles = true, DrawBaseVectorsMes = true, BaseVectorsMesDistance = 1000, BaseVectorsAnglesRadius = 500, DrawHandrail = !noHandrail, DrawHandrailInMes = false, DrawHandrailOutMes = false, DrawHandrailAngles = false, DrawBottomrail = true, DrawBottomrailInMes = false, DrawBottomrailOutMes = false, DrawBottomrailAngles = false, DrawPosts = true, DrawPostsMes = false, PostsMesDistance = 1000, DrawGlassPanels = true, DrawGlassPanelsMes = false, GlassPanelsMesDistance = 1000, DrawJoints = false, DrawOutsideText = true, OutsideTextDistance = 500, MesFontSize = 100 }); balustrade.BalustradeViews.Add(new BalustradeView { Name = "Handrail dimensions", DrawBaseVectors = true, DrawBaseVectorsAngles = true, DrawBaseVectorsMes = true, BaseVectorsMesDistance = 1000, BaseVectorsAnglesRadius = 400, DrawHandrail = true, DrawHandrailInMes = false, DrawHandrailOutMes = true, HandrailOutMesDistance = 600, DrawHandrailAngles = false, DrawBottomrail = true, DrawBottomrailInMes = false, DrawBottomrailOutMes = false, DrawBottomrailAngles = false, DrawPosts = true, DrawPostsMes = true, PostsMesDistance = 200, DrawGlassPanels = true, DrawGlassPanelsMes = false, GlassPanelsMesDistance = 1000, DrawJoints = false, DrawOutsideText = true, OutsideTextDistance = 1400, MesFontSize = 80 }); balustrade.BalustradeViews.Add(new BalustradeView { Name = "Bottomrail dimensions", DrawBaseVectors = true, DrawBaseVectorsAngles = true, DrawBaseVectorsMes = true, BaseVectorsMesDistance = 500, BaseVectorsAnglesRadius = 450, DrawHandrail = false, DrawHandrailInMes = false, DrawHandrailOutMes = false, DrawHandrailAngles = false, DrawBottomrail = true, DrawBottomrailInMes = false, DrawBottomrailOutMes = true, BottomrailOutMesDistance = 250, DrawBottomrailAngles = false, DrawPosts = false, DrawPostsMes = false, DrawGlassPanels = false, DrawGlassPanelsMes = false, DrawJoints = false, DrawOutsideText = true, OutsideTextDistance = 900, MesFontSize = 80 }); balustrade.BalustradeViews.Add(new BalustradeView { Name = "Glass dimensions", DrawBaseVectors = true, DrawBaseVectorsAngles = false, DrawBaseVectorsMes = true, BaseVectorsMesDistance = 500, DrawHandrail = !noHandrail, DrawHandrailInMes = false, DrawHandrailOutMes = false, DrawHandrailAngles = false, DrawBottomrail = true, DrawBottomrailInMes = false, DrawBottomrailOutMes = false, DrawBottomrailAngles = false, DrawPosts = true, DrawPostsMes = false, DrawGlassPanels = true, DrawGlassPanelsMes = true, GlassPanelsMesDistance = 300, DrawJoints = false, DrawOutsideText = true, OutsideTextDistance = 900, MesFontSize = 80 }); }
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); }
public ActionResult Quote(BalustradeQuoteModel model) { if (!model.ModelId.HasValue) { return(RedirectToAction("quote")); } var balustrade = new Balustrade(); balustrade.Color = DbSession.Get <ColorLocal>(model.ColorId); balustrade.GlassSystem = DbSession.Get <GlassSystemLocal>(model.GlassId); balustrade.BalustradeSystem = DbSession.Get <BalustradeSystemLocal>(model.TypeId); balustrade.UpdateSystemDefaults(); balustrade.StartType = BalustradeSection.SectionFinishType.Wall; balustrade.EndType = BalustradeSection.SectionFinishType.Wall; balustrade.ModelId = model.ModelId; var angle = model.Dims.Count > 1 ? 90D : 0D; foreach (var dimension in model.Dims) { var section = new BalustradeSection { Balustrade = balustrade, Angle = angle, Length = dimension.Length ?? 0, Depth = dimension.Curved ? 10 : 0, CalculatePostsQuantity = true, CalculateHandrailJoints = true, PreferStockGlass = balustrade.BalustradeSystem.PreferStockGlass }; balustrade.RawBalustradeSections.Add(section); angle -= 90; } var modelFromDb = DbSession.Get <BalustradeModel>(model.ModelId.Value); Session[SessionKeys.LAST_QUOTE] = new BalustradeQuoteModel(modelFromDb, balustrade, model.P); if (model.Action == BalustradeQuoteModel.AddToCartText) { DbSession.SaveOrUpdate(balustrade); AddToCart(balustrade, 1); DbSession.Flush(); return(RedirectToAction("cart", "customer", new { areas = AreaKind })); } 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(RedirectToAction("create-quote", "customer", new { areas = AreaKind })); }