public ActionResult Create(Product subject) { if (ModelState.IsValid) { db.Products.Add(subject); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(subject)); }
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)); }
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)); }
public void Save() { _context.SaveChanges(); }