Exemplo n.º 1
0
 public Luz Obtener(int id)
 {
     try
     {
         using (ServicioESP_DBEntities db = new ServicioESP_DBEntities())
         {
             return(db.Luz.FirstOrDefault(x => x.Id == id));
         }
     }
     catch (Exception)
     {
         throw new Exception("Ha ocurrido un error al intentar obtener la información de la lampara");
     }
 }
Exemplo n.º 2
0
 public List <Luz> Obtener()
 {
     try
     {
         using (ServicioESP_DBEntities db = new ServicioESP_DBEntities())
         {
             return(db.Luz.ToList());
         }
     }
     catch (Exception ex)
     {
         //throw new Exception ("Ha ocurrido un error al intentar obtener la lista de luces");
         throw new Exception(ex.Message);
     }
 }
Exemplo n.º 3
0
 public void Eliminar(int id)
 {
     try
     {
         using (ServicioESP_DBEntities db = new ServicioESP_DBEntities())
         {
             db.Entry(db.Luz.FirstOrDefault(x => x.Id == id)).State = System.Data.Entity.EntityState.Deleted;
             db.SaveChanges();
         }
     }
     catch (Exception)
     {
         throw new Exception("Ha ocurrido un error al intentar eliminar la lampara.");
     }
 }
Exemplo n.º 4
0
 public void Modificar(Luz lampara)
 {
     try
     {
         using (ServicioESP_DBEntities db = new ServicioESP_DBEntities())
         {
             db.Entry(lampara).State = System.Data.Entity.EntityState.Modified;
             db.SaveChanges();
         }
     }
     catch (Exception)
     {
         throw new Exception("Ha ocurrido un error al intentar modificar la información de la lampara");
     }
 }
Exemplo n.º 5
0
 public void Agregar(Luz lampara)
 {
     try
     {
         using (ServicioESP_DBEntities db = new ServicioESP_DBEntities())
         {
             db.Luz.Add(lampara);
             db.SaveChanges();
         }
     }
     catch (Exception)
     {
         throw new Exception("Ha ocurrido un error al intentar agregar una nueva lampara.");
     }
 }