예제 #1
0
        public ActionResult Update_Order(OrderViewModel order)
        {
            if (order != null && ModelState.IsValid)
            {
                var target = GetOrderByID(order.OrderID);
                target.ShipAddress = order.ShipAddress;
                target.ShipCountry = order.ShipCountry;
                target.ShipName = order.ShipName;
                target.ShippedDate = order.ShippedDate;
                context.SaveChanges();
            }

            return Json(ModelState.ToDataSourceResult());
        }
예제 #2
0
        public ActionResult Create_Order(OrderViewModel order)
        {
            if (order != null && ModelState.IsValid)
            {
                var target = new Order();
                target.ShipAddress = order.ShipAddress;
                target.ShipCountry = order.ShipCountry;
                target.ShipName = order.ShipName;
                target.ShippedDate = order.ShippedDate;
                context.Orders.AddObject(target);
                context.SaveChanges();

                order.OrderID = target.OrderID;
            }

            return Json(new[] { order }.ToDataSourceResult(new DataSourceRequest(), ModelState));
        }