public ActionResult CreateQuoteWithSave(LVGquote lvgquote, string nameOfSubmit)
        {
            if (nameOfSubmit == "Save and Create Pdf")
            {
                {
                    Type = (from b in db.section1Model
                            where b.id == lvgquote.Section1ModelId
                            select b.ProjectType).SingleOrDefault();
                    Branch = (from b in db.section1Model
                            where b.id == lvgquote.Section1ModelId
                            select b.Branch).SingleOrDefault();

                    ViewBag.LiftTypes = GetLiftType1(lvgquote.CodeComplence, lvgquote.id);
                    ViewBag.LiftModels = GetLiftModel1(lvgquote.LiftType, lvgquote.EntranceType);

                    ViewBag.CarWallsLHSS = car.getCarWalls();
                    // ViewBag.CarWallsRHS = car.getCarWalls();
                    //ViewBag.CarWallsRear = car.getCarWalls();
                    ViewBag.powers = Getpower1(lvgquote.LiftType, "fake");
                    ViewBag.CodeComp = car.getobj(Type);
                    ViewBag.Phone = car.getPhone(Type);
                    ViewBag.Ceilings = car.getCeiling();
                    ViewBag.Floors = car.getFloors();
                    ViewBag.Profiles = car.getProfiles();
                    ViewBag.COP = car.getCOP();
                    ViewBag.HandrailTypes = car.getHandRailType(Type);
                    ViewBag.LDFDoorType = car.LDFDoorType(lvgquote.LiftType); ViewBag.LDFDoorFinishs1 = car.LDFDoorFinish(lvgquote.LiftType, lvgquote.LDFDoorType1.Substring(0, 1));
                    ViewBag.LDFDoorFinishs2 = car.LDFDoorFinish(lvgquote.LiftType, lvgquote.LDFDoorType2.Substring(0, 1));
                    ViewBag.LDFDoorFinishs3 = car.LDFDoorFinish(lvgquote.LiftType, lvgquote.LDFDoorType3.Substring(0, 1));
                    ViewBag.LDFDoorFinishs4 = car.LDFDoorFinish(lvgquote.LiftType, lvgquote.LDFDoorType4.Substring(0, 1));
                    ViewBag.LDFDoorFinishs5 = car.LDFDoorFinish(lvgquote.LiftType, lvgquote.LDFDoorType5.Substring(0, 1));
                    ViewBag.LDFDoorFinishs6 = car.LDFDoorFinish(lvgquote.LiftType, lvgquote.LDFDoorType6.Substring(0, 1));
                    ViewBag.LDFDoorFinishs7 = car.LDFDoorFinish(lvgquote.LiftType, lvgquote.LDFDoorType7.Substring(0, 1));
                    ViewBag.LDFDoorFinishs8 = car.LDFDoorFinish(lvgquote.LiftType, lvgquote.LDFDoorType8.Substring(0, 1));
                    ViewBag.LDFDoorFinishs9 = car.LDFDoorFinish(lvgquote.LiftType, lvgquote.LDFDoorType9.Substring(0, 1));
                    ViewBag.LDFDoorFinishs10 = car.LDFDoorFinish(lvgquote.LiftType, lvgquote.LDFDoorType10.Substring(0, 1));
                    ViewBag.StructureFinish = car.getStructureFinish(lvgquote.StructureType);
                    ViewBag.Claddings = car.getCladding(lvgquote.StructureType);
                    ViewBag.entrancetypes = car.getEntranceTypes(lvgquote.EntranceType);

                    // if (lVGquote.TotalSellingPrice == 0)
                    //   ModelState.AddModelError("Name", "Name is required.");

                    try
                    {
                        var actualValue = Convert.ToDecimal(lvgquote.TotalSellingPrice,
                            CultureInfo.CurrentCulture);
                    }
                    catch (FormatException e)
                    {
                        //ModelState.Errors.Add(e);
                        ModelState.AddModelError(e.Message, "Name is required.");
                    }

                    if (ModelState.IsValid)
                    {
                        lvgquote.MyType = "LVGquote";
                        db.Entry(lvgquote).State = EntityState.Modified;
                        db.SaveChanges();
                        //                   return View(lvgquote);
                    }
                }

                if (lvgquote.id == null)
                {
                    return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
                }
                MainQuote lVGquote = db.MainQuote.Find(lvgquote.id);
                if (lVGquote == null)
                {
                    return HttpNotFound();

                }
                PdfDocument paragraph1 = new PdfDocument();

                string QuoteRoot = System.Configuration.ConfigurationManager.AppSettings["QuoteRoot"];
                string filename = "C:\\" + QuoteRoot + "\\" + Branch+"\\" + lVGquote.LiftType + "_P" + lVGquote.Section1ModelId + "-" + lVGquote.id + ".pdf";
                PdfGenerator pdfg = new PdfGenerator();
                paragraph1 = pdfg.CreatePdf(lVGquote);
                paragraph1.Save(filename);
                //// ...and start a viewer
                //   Process.Start(filename);
                var email = new NewCommentEmail
                {
                    To = "*****@*****.**",
                    UserName = lVGquote.id.ToString(),
                    //Comment = "Hello,There is a new comment from " + UserName;
                };
                // email.Attach(new Attachment(filename));
                // email.Send();
                var filesavename = lVGquote.LiftType + "_P" + lVGquote.Section1ModelId + "-" + lVGquote.id + ".pdf";
                return File(filename, "Application/pdf", filesavename);
            }
            else
            {

                {
                    Type = (from b in db.section1Model
                            where b.id == lvgquote.Section1ModelId
                            select b.ProjectType).SingleOrDefault();

                    ViewBag.LiftTypes = GetLiftType1(lvgquote.CodeComplence, lvgquote.id);
                    ViewBag.LiftModels = GetLiftModel1(lvgquote.LiftType, lvgquote.EntranceType);

                    ViewBag.CarWallsLHSS = car.getCarWalls();
                    // ViewBag.CarWallsRHS = car.getCarWalls();
                    //ViewBag.CarWallsRear = car.getCarWalls();
                    ViewBag.powers = Getpower1(lvgquote.LiftType, "fake");
                    ViewBag.CodeComp = car.getobj(Type);
                    ViewBag.Phone = car.getPhone(Type);
                    ViewBag.Ceilings = car.getCeiling();
                    ViewBag.Floors = car.getFloors();
                    ViewBag.Profiles = car.getProfiles();
                    ViewBag.COP = car.getCOP();
                    ViewBag.HandrailTypes = car.getHandRailType(Type);
                    ViewBag.LDFDoorType = car.LDFDoorType(lvgquote.LiftType); ViewBag.LDFDoorFinishs1 = car.LDFDoorFinish(lvgquote.LiftType, lvgquote.LDFDoorType1.Substring(0, 1));
                    ViewBag.LDFDoorFinishs2 = car.LDFDoorFinish(lvgquote.LiftType, lvgquote.LDFDoorType2.Substring(0, 1));
                    ViewBag.LDFDoorFinishs3 = car.LDFDoorFinish(lvgquote.LiftType, lvgquote.LDFDoorType3.Substring(0, 1));
                    ViewBag.LDFDoorFinishs4 = car.LDFDoorFinish(lvgquote.LiftType, lvgquote.LDFDoorType4.Substring(0, 1));
                    ViewBag.LDFDoorFinishs5 = car.LDFDoorFinish(lvgquote.LiftType, lvgquote.LDFDoorType5.Substring(0, 1));
                    ViewBag.LDFDoorFinishs6 = car.LDFDoorFinish(lvgquote.LiftType, lvgquote.LDFDoorType6.Substring(0, 1));
                    ViewBag.LDFDoorFinishs7 = car.LDFDoorFinish(lvgquote.LiftType, lvgquote.LDFDoorType7.Substring(0, 1));
                    ViewBag.LDFDoorFinishs8 = car.LDFDoorFinish(lvgquote.LiftType, lvgquote.LDFDoorType8.Substring(0, 1));
                    ViewBag.LDFDoorFinishs9 = car.LDFDoorFinish(lvgquote.LiftType, lvgquote.LDFDoorType9.Substring(0, 1));
                    ViewBag.LDFDoorFinishs10 = car.LDFDoorFinish(lvgquote.LiftType, lvgquote.LDFDoorType10.Substring(0, 1));
                    ViewBag.StructureFinish = car.getStructureFinish(lvgquote.StructureType);
                    ViewBag.Claddings = car.getCladding(lvgquote.StructureType);
                    ViewBag.entrancetypes = car.getEntranceTypes(lvgquote.EntranceType);

                    // if (lVGquote.TotalSellingPrice == 0)
                    //   ModelState.AddModelError("Name", "Name is required.");

                    try
                    {
                        var actualValue = Convert.ToDecimal(lvgquote.TotalSellingPrice,
                            CultureInfo.CurrentCulture);
                    }
                    catch (FormatException e)
                    {
                        //ModelState.Errors.Add(e);
                        ModelState.AddModelError(e.Message, "Name is required.");
                    }

                    if (ModelState.IsValid)
                    {
                        lvgquote.MyType = "LVGquote";
                        db.Entry(lvgquote).State = EntityState.Modified;
                        db.SaveChanges();
                        //return View(lvgquote);
                    }
                    return RedirectToAction("Edit", "LVGquotes", new { id = lvgquote.id });
                }

            }
        }
        public string SendEmail1(NewCommentEmail data)
        {
            MainQuote lVGquote = db.MainQuote.Find(data.quoteID);

            var email = new NewCommentEmail
            {
                To = data.To,
                UserName = data.UserName,
                Comment = data.Comment

            };

            // check if quotes checkbox is ticked
            if (data.Quote)
            {
                email.Attach(new Attachment(data.filename));

            }

            // check if  brochure is ticked in
            if (data.brochure)
            {
                // check lift types copy this code for other type of lifts
                if (lVGquote.LiftType == "DomusLift")
                {
                    email.Attach(new Attachment(System.Web.HttpContext.Current.Server.MapPath("~\\Content\\Brochure\\IGV-DomusLift-Brochure-eng.pdf")));
                }// email.Attach(new Attachment("C:\\DreamerQuotes\\dd1.txt"));
            }

            // check if  sample drowings is ticked
            if (data.SampleDrawings)
            {   // if shaft type is masonry
                if (lVGquote.ShaftType == "Masonry")
                {
                    // if lift type is DomusLift
                    if (lVGquote.LiftType == "DomusLift")
                    {

                        //if load bearing wall if left
                        if (lVGquote.LoadBearingWall == "Left")
                        {

                        }
                        //if load bearing wall is right
                        {

                        }
                    }
                    // if lift type is Domusxl
                    if (lVGquote.LiftType == "DomusLift")
                    {

                        //if load bearing wall if left
                        if (lVGquote.LoadBearingWall == "Left")
                        {

                        }
                        //if load bearing wall is right
                        {

                        }
                    }
                }
                // if shaft type is not masonary
                else
                {
                    if (lVGquote.LiftType == "DomusLift")
                    {

                        //if load bearing wall if left
                        if (lVGquote.LoadBearingWall == "Left")
                        {

                        }
                        //if load bearing wall is right
                        {

                        }
                    }
                    // if lift type is Domusxl
                    if (lVGquote.LiftType == "DomusLift")
                    {

                        //if load bearing wall if left
                        if (lVGquote.LoadBearingWall == "Left")
                        {

                        }
                        //if load bearing wall is right
                        {

                        }
                    }

                }
            }

            email.Send();

            return "Email Sent";
        }
        //create quote
        public ActionResult CreateQuote(int? id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            MainQuote lVGquote = db.MainQuote.Find(id);
            if (lVGquote == null)
            {
                return HttpNotFound();

            }

            Branch = (from b in db.section1Model
                      where b.id == lVGquote.Section1ModelId
                      select b.Branch).SingleOrDefault();
            PdfDocument paragraph1 = new PdfDocument();
            string QuoteRoot = System.Configuration.ConfigurationManager.AppSettings["QuoteRoot"];
              //  string filename = "\\\\elhe-syd-ad1\\" + QuoteRoot + "\\" + Branch + "\\Quote" + lVGquote.id + ".pdf";
            string filename = "C:\\" + QuoteRoot + "\\" + Branch + "\\" + lVGquote.LiftType + "_P" + lVGquote.Section1ModelId + "-" + lVGquote.id + ".pdf";
            PdfGenerator pdfg = new PdfGenerator();
            paragraph1 = pdfg.CreatePdf(lVGquote);
            paragraph1.Save(filename);
            //// ...and start a viewer
            //   Process.Start(filename);
            var email = new NewCommentEmail
            {
                To = "*****@*****.**",
                UserName = lVGquote.id.ToString(),
                //Comment = "Hello,There is a new comment from " + UserName;
            };
            // email.Attach(new Attachment(filename));
            // email.Send();
            var filesavename = lVGquote.LiftType + "_P" + lVGquote.Section1ModelId + "-" + lVGquote.id + ".pdf";
            return File(filename, "Application/pdf", filesavename);
        }