public static bool Create(PartItem partItem) { bool result = true; try { db.PartItems.AddObject(partItem); db.SaveChanges(); } catch (Exception) { result = false; } return result; }
public static bool Update(PartItem partItem) { bool result = true; try { EntityDataModelContainer mc = new EntityDataModelContainer(); mc.PartItems.Attach(partItem); mc.ObjectStateManager.ChangeObjectState(partItem, EntityState.Modified); mc.SaveChanges(); db.Refresh(System.Data.Objects.RefreshMode.StoreWins, partItem); } catch (Exception) { result = false; } return result; }
/// <summary> /// Deprecated Method for adding a new object to the PartItems EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToPartItems(PartItem partItem) { base.AddObject("PartItems", partItem); }
/// <summary> /// Create a new PartItem object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="part_id">Initial value of the Part_id property.</param> /// <param name="serial_num">Initial value of the Serial_num property.</param> /// <param name="supplier_id">Initial value of the Supplier_id property.</param> /// <param name="date_in">Initial value of the Date_in property.</param> /// <param name="price">Initial value of the Price property.</param> public static PartItem CreatePartItem(global::System.Int32 id, global::System.Int32 part_id, global::System.String serial_num, global::System.Int32 supplier_id, global::System.DateTime date_in, global::System.Decimal price) { PartItem partItem = new PartItem(); partItem.Id = id; partItem.Part_id = part_id; partItem.Serial_num = serial_num; partItem.Supplier_id = supplier_id; partItem.Date_in = date_in; partItem.Price = price; return partItem; }