Пример #1
0
        //BLL Bussiness Logic Layer
        //Capa de Logica del Negocio

        public static void Create(Pelicula p)
        {
            using (ServicioStreamEntities db = new ServicioStreamEntities())
            {
                using (var transaction = db.Database.BeginTransaction())
                {
                    try
                    {
                        db.Pelicula.Add(p);
                        db.SaveChanges();
                        transaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();
                        throw ex;
                    }
                }
            }
        }
Пример #2
0
 public static void Delete(int?id)
 {
     using (ServicioStreamEntities db = new ServicioStreamEntities())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             try
             {
                 Pelicula pelicula = db.Pelicula.Find(id);
                 db.Entry(pelicula).State = System.Data.Entity.EntityState.Deleted;
                 db.SaveChanges();
                 transaction.Commit();
             }
             catch (Exception ex)
             {
                 transaction.Rollback();
                 throw ex;
             }
         }
     }
 }
Пример #3
0
 public static void Update(Pelicula pelicula)
 {
     using (ServicioStreamEntities db = new ServicioStreamEntities())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             try
             {
                 db.Pelicula.Attach(pelicula);
                 db.Entry(pelicula).State = System.Data.Entity.EntityState.Modified;
                 db.SaveChanges();
                 transaction.Commit();
             }
             catch (Exception ex)
             {
                 transaction.Rollback();
                 throw ex;
             }
         }
     }
 }