示例#1
0
        public static bool Create(Warranty warranty)
        {
            bool result = true;
            try
            {
                db.Warranties.AddObject(warranty);
                db.SaveChanges();
            }
            catch (Exception)
            {
                result = false;
            }

            return result;
        }
示例#2
0
        public static bool Update(Warranty warranty)
        {
            bool result = true;
            try
            {
                EntityDataModelContainer mc = new EntityDataModelContainer();
                mc.Warranties.Attach(warranty);
                mc.ObjectStateManager.ChangeObjectState(warranty, EntityState.Modified);
                mc.SaveChanges();
                db.Refresh(System.Data.Objects.RefreshMode.StoreWins, warranty);
            }
            catch (Exception)
            {
                result = false;
            }

            return result;
        }
 /// <summary>
 /// Create a new Warranty object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="updated_at">Initial value of the Updated_at property.</param>
 public static Warranty CreateWarranty(global::System.Int32 id, global::System.String name, global::System.DateTime updated_at)
 {
     Warranty warranty = new Warranty();
     warranty.Id = id;
     warranty.Name = name;
     warranty.Updated_at = updated_at;
     return warranty;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Warranties EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToWarranties(Warranty warranty)
 {
     base.AddObject("Warranties", warranty);
 }