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); } }
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); } }
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); }