Beispiel #1
0
 public void Update(T entity)
 {
     using (var context = new PwContext())
     {
         context.Entry <T>(entity).State = EntityState.Modified;
         context.SaveChanges();
     }
 }
Beispiel #2
0
 public void Create(T entity)
 {
     using (var context = new PwContext())
     {
         context.Set <T>().Add(entity);
         context.SaveChanges();
     }
 }
 public new void Create(Transaction entity)
 {
     using (var context = new PwContext())
     {
         context.Set <User>().Attach(entity.CorrespondentUser);
         context.Set <User>().Attach(entity.OwnerUser);
         context.Set <Transaction>().Add(entity);
         context.SaveChanges();
     }
 }
Beispiel #4
0
 public void Remove(int id)
 {
     using (var context = new PwContext())
     {
         var entity = context.Set <T>().FirstOrDefault(e => e.ID == id);
         if (entity != null)
         {
             context.Set <T>().Remove(entity);
             context.SaveChanges();
         }
     }
 }