Example #1
0
        public ActionResult Create([Bind(Include = "OrderId,ProductId,UnitPrice,Quantity,Discount")] OrderDetail orderDetail)
        {
            if (ModelState.IsValid)
            {
                db.OrderDetails.Add(orderDetail);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.OrderId   = new SelectList(db.Orders, "Id", "CustomerId", orderDetail.OrderId);
            ViewBag.ProductId = new SelectList(db.Products, "Id", "ProductName", orderDetail.ProductId);
            return(View(orderDetail));
        }