Example #1
0
 public void Delete(TEntity entity)
 {
     using (var context = new SGBContext())
     {
         context.Entry(entity).State = EntityState.Deleted;
         context.SaveChanges();
     }
 }
Example #2
0
 public TEntity Add(TEntity entity)
 {
     using (var context = new SGBContext())
     {
         context.Entry(entity).State = EntityState.Added;
         context.SaveChanges();
         return(entity);
     }
 }
Example #3
0
 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);
     }
 }