public async Task <IEnumerable <TEntity> > GetNotDeletedAsync() { using (var db = new DpContext()) { return(await db.Set <TEntity>().Where(t => !t.Deleted).ToListAsync()); } }
public async Task <IEnumerable <TEntity> > GetAllAsync() { using (var db = new DpContext()) { return(await db.Set <TEntity>().ToListAsync()); } }
public async Task <TEntity> GetByIdAsync(int id) { using (var db = new DpContext()) { return(await db.Set <TEntity>().FindAsync(id)); } }
public async Task <int> CreateAsync(TEntity entity) { using (var db = new DpContext()) { db.Set <TEntity>().Add(entity); await db.SaveChangesAsync(); return(entity.Id); } }
public async Task UpdateAsync(TEntity entity) { using (var db = new DpContext()) { entity.ModifiedDateTime = DateTimeOffset.UtcNow; db.Set <TEntity>().Attach(entity); db.Entry(entity).State = EntityState.Modified; await db.SaveChangesAsync(); } }