// // GET: /RequestParts/Create public ActionResult Create(int requestItemId) { ViewBag.Part_id = new SelectList(db.Parts, "Id", "Description"); ViewBag.PartItem_id = new SelectList(db.PartItems.Where(pi => pi.Id == -1), "Id", "Serial_num"); ViewBag.Supplier_id = new SelectList(db.Suppliers, "Id", "Name"); var part = new RequestItemPart(); part.RequestItem_id = requestItemId; return View(part); }
public ActionResult Create(RequestItemPart requestpart) { if (ModelState.IsValid) { db.RequestItemParts.AddObject(requestpart); db.SaveChanges(); return RedirectToAction("Edit", "RequestItems", new { @id = requestpart.RequestItem_id }); } ViewBag.PartItem_id = new SelectList(db.PartItems, "Id", "Serial_num", requestpart.PartItem_id); ViewBag.RequestItem_id = new SelectList(db.RequestItems, "Id", "Name", requestpart.RequestItem_id); return View(requestpart); }
public static bool Create(RequestItemPart requestItemPart) { bool result = true; try { db.RequestItemParts.AddObject(requestItemPart); db.SaveChanges(); } catch (Exception) { result = false; } return result; }
public static bool Update(RequestItemPart requestItemPart) { bool result = true; try { EntityDataModelContainer mc = new EntityDataModelContainer(); mc.RequestItemParts.Attach(requestItemPart); mc.ObjectStateManager.ChangeObjectState(requestItemPart, EntityState.Modified); mc.SaveChanges(); db.Refresh(System.Data.Objects.RefreshMode.StoreWins, requestItemPart); } catch (Exception) { result = false; } return result; }
public ActionResult Edit(RequestItemPart requestpart) { if (ModelState.IsValid) { db.RequestItemParts.Attach(requestpart); db.ObjectStateManager.ChangeObjectState(requestpart, EntityState.Modified); db.SaveChanges(); return RedirectToAction("Edit", "RequestItems", new { @id = requestpart.RequestItem_id }); } ViewBag.PartItem_id = new SelectList(db.PartItems, "Id", "Serial_num", requestpart.PartItem_id); ViewBag.RequestItem_id = new SelectList(db.RequestItems, "Id", "Name", requestpart.RequestItem_id); return View(requestpart); }
/// <summary> /// Deprecated Method for adding a new object to the RequestItemParts EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToRequestItemParts(RequestItemPart requestItemPart) { base.AddObject("RequestItemParts", requestItemPart); }
/// <summary> /// Create a new RequestItemPart object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="requestItem_id">Initial value of the RequestItem_id property.</param> /// <param name="partItem_id">Initial value of the PartItem_id property.</param> public static RequestItemPart CreateRequestItemPart(global::System.Int32 id, global::System.Int32 requestItem_id, global::System.Int32 partItem_id) { RequestItemPart requestItemPart = new RequestItemPart(); requestItemPart.Id = id; requestItemPart.RequestItem_id = requestItem_id; requestItemPart.PartItem_id = partItem_id; return requestItemPart; }