예제 #1
0
        public ActionResult Create(Product subject)
        {
            if (ModelState.IsValid)
            {
                db.Products.Add(subject);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(subject));
        }
예제 #2
0
        public ActionResult Create([Bind(Include = "Id,CustomerId,TotalPrice")] Order order)
        {
            if (ModelState.IsValid)
            {
                db.Orders.Add(order);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CustomerId = new SelectList(db.Customers, "Id", "Name", order.CustomerId);
            return(View(order));
        }
예제 #3
0
        public ActionResult Create([Bind(Include = "Id,ProductId,Quantity,OrderId")] OrderDetail orderDetail)
        {
            if (ModelState.IsValid)
            {
                db.OrderDetails.Add(orderDetail);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.OrderId   = new SelectList(db.Orders, "Id", "Id", orderDetail.OrderId);
            ViewBag.ProductId = new SelectList(db.Products, "Id", "Title", orderDetail.ProductId);
            return(View(orderDetail));
        }
예제 #4
0
 public void Save()
 {
     _context.SaveChanges();
 }