public void AddorUpdate(Order order)
 {
     if (order.OrderID > 0)
     {
         Order oid = this.GetOrderById(order.OrderID);
         dbcontext.Entry(oid).CurrentValues.SetValues(order);
     }
     else
     {
         dbcontext.Orders.Add(order);
     }
      dbcontext.SaveChanges();
 }
        //public void CreateDict([Bind(Include = "prod,quantity")] ClientOrderViewModel cc)
        //{
        //    if (prodDict.ContainsKey(cc.prod))
        //    {
        //        prodDict[cc.prod] = prodDict[cc.prod] + cc.Quantity;
        //    }
        //    else
        //    {
        //        prodDict.Add(cc.prod, cc.Quantity);
        //    }
        //}
        //    //cc.OrderedProducts = GetOrderList(orderID);
        //    //AllProducts = cd.ListProducts();
        //    //cc.AllProducts = AllProducts;
        //    //// cc.OrderedProducts = AllProductsOrder;
        //    //return View("Create", cc);
        //}
        // public ActionResult CreateOrder()
        public void CreateOrder(int RetailerID, int StoreID, string datepicker)
        {
            Order order = new Order();
            order.RetailerID = RetailerID;
            order.StoreID = StoreID;
            order.Status = "PE";
            order.DeliveryDate = Convert.ToDateTime(datepicker);
            //order.RetailerID = 4;
            //order.StoreID = 4;
            //order.Status = "PE";
            //order.DeliveryDate = null;

            ClientOrderDAL clientorder = new ClientOrderDAL();
            clientorder.AddorUpdate(order);

            foreach (KeyValuePair<int, int> entry in prodDict)
            {
                OrderProduct orderproduct = new OrderProduct();
                orderproduct.OrderID = order.OrderID;
                orderproduct.ProductID = entry.Key;
                orderproduct.Quantity = entry.Value;
                clientorder.AddorUpdateOrderProducts(orderproduct);
            }

            //ClientOrderViewModel orderprod = new ClientOrderViewModel();
            //orderprod.AllProducts = AllProducts;
            //orderprod.OrderedProducts = cd.AllOrderedProduct(order.OrderID);
            //ViewBag.StoreID = new SelectList(db.Stores, "StoreID", "Name");
            //ViewBag.RetailerID = new SelectList(db.Retailers, "RetailerID", "Name");
            //return View("Create", orderprod);

            orderID = order.OrderID;
            ViewBag.StoreID = new SelectList(db.Stores, "StoreID", "Name");
            ViewBag.RetailerID = new SelectList(db.Retailers, "RetailerID", "Name");
            //return orderID;
            CreateFinal(orderID);
            //return RedirectToAction("CreateFinal");
        }