public void Delete(TEntity entity) { using (var context = new SGBContext()) { context.Entry(entity).State = EntityState.Deleted; context.SaveChanges(); } }
public TEntity Add(TEntity entity) { using (var context = new SGBContext()) { context.Entry(entity).State = EntityState.Added; context.SaveChanges(); return(entity); } }
public TEntity Update(TEntity entity) { using (var context = new SGBContext()) { context.Entry(entity).State = entity.Id == 0 ? EntityState.Added : EntityState.Modified; context.SaveChanges(); return(entity); } }