public ActionResult CreateAndAddProducts([ModelBinder(typeof(OrderBinderCreate))]  OrderCreateViewModel ocvm, string[] DeliveryID)
        {
            if (ModelState.IsValid)
            {
                //aanmaken van quotation / customerdeliveryaddress en customer
                Order order = new Order();
                CustomerDeliveryAddress cda = new CustomerDeliveryAddress();
                Customer cus = new Customer();

                //ophalen van customerDeliveryAddressID vanuit de array
                // eventueel nog test inbouwen voor lengte van array (check dat ze niet meer als 1 veld selecteren)
                int DeliveryId = 1;
                if (DeliveryID.Length == 1)
                {
                    DeliveryId = Int32.Parse(DeliveryID.First());
                }
                else
                {
                    return RedirectToAction("Create");
                }

                // ophalen delivery info en van daaruit customer info
                cda = db.CustomerDeliveryAddresses.Find(DeliveryId);
                cus = db.Customers.Find(cda.CustomerId);

                // invullen van de klant info in de quotation
                DefaultOrderInfo(order);
                order.FirstName = cus.FirstName;
                order.LastName = cus.LastName;
                order.Box = cus.Address.Box;
                order.CellPhone = cus.CellPhone;
                order.CustomerId = cus.CustomerId;
                order.Email = cus.Email;
                order.PostalCodeNumber = cus.Address.PostalCodeNumber;
                order.StreetName = cus.Address.StreetName;
                order.StreetNumber = cus.Address.StreetNumber;
                order.Town = cus.Address.Town;
                order.Annotation = ocvm.order.Annotation;
                order.customerDeliveryAddress = db.CustomerDeliveryAddresses.Find(DeliveryId);

                //toevoegen en saven
                db.Orders.Add(order);
                db.SaveChanges();

                int id = order.OrderId;
                TempData["id"] = id;
                return RedirectToAction("AddProducts");

            }
            return View(ocvm);
        }
        public ActionResult AddDeliveryAddress([ModelBinder(typeof(CustomerBinderAddNewDeliveryAddress))] CustomerAddDeliveryAddressViewModel cadavm, string[] AddressId, string returnUrl)
        {
            Customer cus = new Customer();
            Address add = new Address();
            CustomerDeliveryAddress cda = new CustomerDeliveryAddress();
            cus = db.Customers.Find(cadavm.deliveryAddress.CustomerId);

            if (AddressId != null)
            {
                if (AddressId.Length > 1)
                {
                    return RedirectToAction("AddDeliveryAddress");
                }

                if (AddressId.Length == 1)
                {
                    add = db.Addresses.Find(Int32.Parse(AddressId.First()));
                    cda.Box = add.Box;
                    cda.CustomerId = cadavm.customer.CustomerId;
                    cda.DeliveryAddressInfo = cadavm.deliveryAddress.DeliveryAddressInfo;
                    cda.PostalCodeNumber = add.PostalCodeNumber;
                    cda.StreetName = add.StreetName;
                    cda.StreetNumber = add.StreetNumber;
                    cda.Town = add.Town;
                    cus.CustomerDeliveryAddress.Add(cda);
                    db.SaveChanges();
                    return Redirect(returnUrl);
                }
            }

            cda = cadavm.deliveryAddress;
            cus.CustomerDeliveryAddress.Add(cda);
            db.SaveChanges();
            return Redirect(returnUrl);
        }
        public ActionResult Create([ModelBinder(typeof(CustomerBinderCreate))] CustomerCreateViewModel ccvm)
        {
            if (ModelState.IsValid)
            {
                // aanmaken lege opbjecten
                Customer cus = new Customer();
                CustomerDeliveryAddress cda = new CustomerDeliveryAddress();

                //opslaan van klant
                cus = ccvm.customer;
                db.Customers.Add(cus);
                db.SaveChanges();

                // vullen van delivery Address met default info
                cda.Box = cus.Address.Box;
                cda.PostalCodeNumber = cus.Address.PostalCodeNumber;
                cda.StreetName = cus.Address.StreetName;
                cda.StreetNumber = cus.Address.StreetNumber;
                cda.Town = cus.Address.Town;
                cda.CustomerId = cus.CustomerId;
                cda.DeliveryAddressInfo = "Standaard adres";
                db.CustomerDeliveryAddresses.Add(cda);
                db.SaveChanges();

                //redirect to index
                return RedirectToAction("Index");
            }
            return View(ccvm);
        }
        public ActionResult Create([ModelBinder(typeof(QuotationBinderCreate))]  QuotationCreateViewModel qcvm, string[] DeliveryID)
        {
            if (ModelState.IsValid)
            {
                //aanmaken van quotation / customerdeliveryaddress en customer
                Quotation quotation = new Quotation();
                CustomerDeliveryAddress cda = new CustomerDeliveryAddress();
                Customer cus = new Customer();

                //ophalen van customerDeliveryAddressID vanuit de array
                // eventueel nog test inbouwen voor lengte van array (check dat ze niet meer als 1 veld selecteren)
                int DeliveryId = 1;
                if (DeliveryID.Length == 1)
                {
                    DeliveryId = Int32.Parse(DeliveryID.First());
                }
                else
                {
                   return RedirectToAction("Create");
                }

                // ophalen delivery info en van daaruit customer info
                cda = db.CustomerDeliveryAddresses.Find(DeliveryId);
                cus = db.Customers.Find(cda.CustomerId);

                // invullen van de klant info in de quotation
                DefaultQuotationInfo(quotation);
                quotation.FirstName = cus.FirstName;
                quotation.LastName = cus.LastName;
                quotation.Box = cus.Address.Box;
                quotation.CellPhone = cus.CellPhone;
                quotation.CustomerId = cus.CustomerId;
                quotation.Email = cus.Email;
                quotation.PostalCodeNumber = cus.Address.PostalCodeNumber;
                quotation.StreetName = cus.Address.StreetName;
                quotation.StreetNumber = cus.Address.StreetNumber;
                quotation.Town = cus.Address.Town;
                quotation.Annotation = qcvm.quotation.Annotation;
                quotation.customerDeliveryAddress = db.CustomerDeliveryAddresses.Find(DeliveryId);

                //toevoegen en saven
                db.Quotations.Add(quotation);
                db.SaveChanges();

                return RedirectToAction("Index");
            }
            return View(qcvm);
        }