예제 #1
0
 public void ModifyEntity(TEntity entity)
 {
     try
     {
         using (var context = new PlanAnualOperativoAntony2020Entities())
         {
             context.Entry(entity).State = EntityState.Modified;
             context.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw new Exception("No se puede actualizar el registro", ex);
     }
 }
예제 #2
0
 public void DeleteEntity(int id)
 {
     try
     {
         using (var context = new PlanAnualOperativoAntony2020Entities())
         {
             var entity = context.Set <TEntity>().Find(id);
             context.Set <TEntity>().Remove(entity);
             context.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw new Exception("No se puede eliminar el registro", ex);
     }
 }
예제 #3
0
        public TEntity AddEntity(TEntity entity)
        {
            TEntity created = null;

            try
            {
                using (var context = new PlanAnualOperativoAntony2020Entities())
                {
                    created = context.Set <TEntity>().Add(entity);
                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw new Exception("No se puede guardar el registro", ex);
            }

            return(created);
        }