public ActionResult Create(OrderItem orderitem) { if (ModelState.IsValid) { db.OrderItems.Add(orderitem); db.SaveChanges(); return RedirectToAction("Index", "OrderItem", new { Order_ID = orderitem.Order_ID }); } ViewBag.Item_ID = new SelectList(db.Items, "ID", "Name", orderitem.Item_ID); ViewBag.Order_ID = new SelectList(db.Orders, "ID", "ID", orderitem.Order_ID); return View(orderitem); }
public ActionResult Edit(OrderItem orderitem) { if (ModelState.IsValid) { db.Entry(orderitem).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.Item_ID = new SelectList(db.Items, "ID", "Name", orderitem.Item_ID); ViewBag.Order_ID = new SelectList(db.Orders, "ID", "ID", orderitem.Order_ID); ViewBag.currentOrder = orderitem.Order_ID; return View(orderitem); }