public ActionResult CopyQuotation(int? Id)
        {
            Quotation quotNew = new Quotation();
            Quotation quotOld = new Quotation();
            quotOld = db.Quotations.Find(Id);

            //check of er al een copy is
            List<Quotation> quotlist = db.Quotations.ToList();
            var checkQuotNumber  = quotlist.Where(q => q.QuotationNumber == quotOld.QuotationNumber);

            if (checkQuotNumber.Count() == 1)
            {
                quotNew.Annotation = quotOld.Annotation + " - Copy";
                quotNew.Active = quotOld.Active;
                quotNew.Box = quotOld.Box;
                quotNew.CellPhone = quotOld.CellPhone;
                quotNew.CustomerId = quotOld.CustomerId;
                quotNew.Date = quotOld.Date;
                quotNew.Email = quotOld.Email;
                quotNew.ExpirationDate = quotOld.ExpirationDate;
                quotNew.FirstName = quotOld.FirstName;
                quotNew.LastName = quotOld.LastName;
                quotNew.PostalCodeNumber = quotOld.PostalCodeNumber;
                quotNew.QuotationNumber = quotOld.QuotationNumber;
                quotNew.StreetName = quotOld.StreetName;
                quotNew.StreetNumber = quotOld.StreetNumber;
                quotNew.TotalPrice = 0;
                quotNew.Town = quotOld.Town;

                db.Quotations.Add(quotNew);
                db.SaveChanges();

                var delivery = db.CustomerDeliveryAddresses.Find(quotOld.customerDeliveryAddress.CustomerDeliveryAddressId);
                quotNew.customerDeliveryAddress = delivery;

                foreach (var item in quotOld.QuotationDetail)
                {

                    var qd = new QuotationDetail();
                    qd.Quantity = 1;
                    qd.PriceExVAT = 0;
                    qd.TotalExVat = 0;
                    qd.TotalIncVat = 0;
                    qd.Auvibel = item.Auvibel;
                    qd.Bebat = item.Bebat;
                    qd.Brand = item.Brand;
                    qd.CategoryId = item.CategoryId;
                    qd.Description = item.Description;
                    qd.ProductCode = item.ProductCode;
                    qd.ProductName = item.ProductName;
                    qd.Recupel = item.Recupel;
                    qd.Reprobel = item.Reprobel;
                    qd.VATPercId = item.VATPercId;
                    qd.ProductId = item.ProductId;
                    qd.QuotationId = quotNew.QuotationId;
                    qd.VAT = item.VAT;
                    db.QuotationDetails.Add(qd);

                }

                db.SaveChanges();
            }
            else
            {
                TempData["error"] = "Er is reeds een copy van deze offerte";
            }
            return RedirectToAction("index");
        }
        public ActionResult AddProductToQuotation(int? quotationId, int? productId)
        {
            // find op quotation en product
            var quotItem = db.QuotationDetails.SingleOrDefault(q => q.QuotationId == quotationId && q.ProductId == productId);
            Product prod = db.Products.Find(productId);

            // nieuwe quotation detail
            if (quotItem == null)
            {
                quotItem = new QuotationDetail
                {
                    ProductId = (int)productId,
                    QuotationId = (int)quotationId,
                    Quantity = 1,
                    Auvibel = prod.Auvibel,
                    Bebat = prod.Bebat,
                    CategoryId = prod.CategoryId,
                    Brand = prod.Brand,
                    Description = prod.Description,
                    PriceExVAT = prod.PriceExVAT,
                    ProductCode = prod.ProductCode,
                    ProductName = prod.ProductName,
                    Recupel = prod.Recupel,
                    Reprobel = prod.Reprobel,
                    VATPercId = prod.VATPercId,
                };
                quotItem.VAT = db.VATs.Find(quotItem.VATPercId);
                db.QuotationDetails.Add(quotItem);
            }
            else
            {
                quotItem.Quantity++;
            }
            quotItem.TotalExVat = (quotItem.PriceExVAT + quotItem.Auvibel + quotItem.Bebat + quotItem.Recupel + quotItem.Reprobel) * quotItem.Quantity;
            //Berekent totaal per lijn van producten inc BTW
            quotItem.TotalIncVat = quotItem.TotalExVat * (1 + (quotItem.VAT.VATValue / 100));
            CalculateTotalPriceinc(quotationId);
            db.SaveChanges();

            return RedirectToAction("AddProducts", new { id= quotationId });
        }