public User Get(string email) { using (var context = new PwContext()) { return(context.Set <User>().FirstOrDefault(e => e.Email == email)); }; }
public T Get(int id) { using (var context = new PwContext()) { return(context.Set <T>().FirstOrDefault <T>(e => e.ID == id)); } }
public IEnumerable <T> GetAll() { using (var context = new PwContext()) { var result = context.Set <T>().ToList(); return(result); } }
public void Update(T entity) { using (var context = new PwContext()) { context.Entry <T>(entity).State = EntityState.Modified; context.SaveChanges(); } }
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(); } }
public IEnumerable <Transaction> GetByUser(int userId) { using (var context = new PwContext()) { var result = context.Set <Transaction>() .Include("OwnerUser") .Include("CorrespondentUser") .Where(t => t.OwnerUser.ID == userId) .ToList(); return(result); } }
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(); } } }