示例#1
0
 public static void Delete(int?id)
 {
     using (dbPortalVideosEntities db = new dbPortalVideosEntities())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             try
             {
                 Video alumno = db.Video.Find(id);
                 db.Entry(alumno).State = System.Data.Entity.EntityState.Deleted;
                 db.SaveChanges();
                 transaction.Commit();
             }
             catch (Exception ex)
             {
                 transaction.Rollback();
                 throw ex;
             }
         }
     }
 }
示例#2
0
 public static void Update(Video alumno)
 {
     using (dbPortalVideosEntities db = new dbPortalVideosEntities())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             try
             {
                 db.Video.Attach(alumno);
                 db.Entry(alumno).State = System.Data.Entity.EntityState.Modified;
                 db.SaveChanges();
                 transaction.Commit();
             }
             catch (Exception ex)
             {
                 transaction.Rollback();
                 throw ex;
             }
         }
     }
 }