Пример #1
0
 public override void Update(Sellers obj)
 {
     using (WholesaleStoreEntities db = new WholesaleStoreEntities())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             try
             {
                 db.Entry(obj).State = EntityState.Modified;
                 db.SaveChanges();
                 transaction.Commit();
             }
             catch (Exception)
             {
                 transaction.Rollback();
                 throw;
             }
         }
     }
 }
Пример #2
0
 public override void Delete(int id)
 {
     using (WholesaleStoreEntities db = new WholesaleStoreEntities())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             try
             {
                 var product = db.Products.Find(id);
                 db.Entry(product).State = EntityState.Deleted;
                 db.SaveChanges();
                 transaction.Commit();
             }
             catch (Exception)
             {
                 transaction.Rollback();
                 throw;
             }
         }
     }
 }