Example #1
0
        //BLL Bussiness Logic Layer
        //Capa de Logica del Negocio

        public static void Create(Video a)
        {
            using (dbPortalVideosEntities db = new dbPortalVideosEntities())
            {
                using (var transaction = db.Database.BeginTransaction())
                {
                    try
                    {
                        db.Video.Add(a);
                        db.SaveChanges();
                        transaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();
                        throw ex;
                    }
                }
            }
        }
Example #2
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;
             }
         }
     }
 }
Example #3
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;
             }
         }
     }
 }
Example #4
0
        public static List <Video> List()
        {
            dbPortalVideosEntities db = new dbPortalVideosEntities();

            return(db.Video.ToList());
        }
Example #5
0
        public static Video Get(int?id)
        {
            dbPortalVideosEntities db = new dbPortalVideosEntities();

            return(db.Video.Find(id));
        }