public ActionResult EditOrder(OrderViewModel model)
        {
            if (ModelState.IsValid)
            {

                var original = db.Orders.Find(model.order.Id);
                if (original != null)
                {
                    original.City = model.order.City;
                    original.Country = model.order.Country;
                    original.Email = model.order.Email;
                    original.LastName = model.order.LastName;
                    original.FirstName = model.order.FirstName;
                    original.MiddleName = model.order.MiddleName;
                    original.Phone = model.order.Phone;
                    original.Total = model.order.Total;
                    original.TextInfo = model.order.TextInfo;
                    original.MethodOfDeliveryId = model.order.MethodOfDeliveryId;
                    original.MethodOfPaymentId = model.order.MethodOfPaymentId;
                    original.OrderStatusId = model.order.OrderStatusId;
                    db.SaveChanges();
                }
                if (model.order.OrderStatusId == StatusOrder.New) return RedirectToAction("BrowseNewOrders");
                else if (model.order.OrderStatusId == StatusOrder.InProcessing)
                    return RedirectToAction("BrowseOrdersInProcessing");
                else return RedirectToAction("BrowseExecutedOrders");
            }
            ViewBag.OrderStatusId = new SelectList(db.OrderStatuses.ToList(), "Id", "Name", model.order.OrderStatusId);
            ViewBag.MethodOfDeliveryId = new SelectList(db.MethodOfDeliveries.ToList(), "Id", "Name",
                model.order.MethodOfDeliveryId);
            ViewBag.MethodOfPaymentId = new SelectList(db.MethodOfPayments.ToList(), "Id", "Name",
                model.order.MethodOfPaymentId);
            return View(model);
        }
        public ActionResult EditOrder(int id)
        {
            var or = db.Orders.First(t => t.Id == id);
            if (or == null) return HttpNotFound();

            var orDetails = db.OrderDetails.Where(i => i.OrderId == or.Id).ToList();

            // var list = orDetails.Where(t => t.OrderId == id).ToList();
            var model = new OrderViewModel
            {
                order = or,
                orderDetails = orDetails
            };

            ViewBag.OrderStatusId = new SelectList(db.OrderStatuses.ToList(), "Id", "Name", model.order.OrderStatusId);
            ViewBag.MethodOfDeliveryId = new SelectList(db.MethodOfDeliveries.ToList(), "Id", "Name",
                model.order.MethodOfDeliveryId);
            ViewBag.MethodOfPaymentId = new SelectList(db.MethodOfPayments.ToList(), "Id", "Name",
                model.order.MethodOfPaymentId);
            return View(model);
        }