public async Task <TEntity> Update(TEntity entity) { using (var dbContext = new raw2Context()) { dbContext.Entry(entity).State = EntityState.Modified; await dbContext.SaveChangesAsync(); return(entity); } }
public async Task <TEntity> Create(TEntity entity) { using (var dbContext = new raw2Context()) { dbContext.Set <TEntity>().Add(entity); await dbContext.SaveChangesAsync(); return(entity); } }
public async Task <bool> Delete(int id) { using (var dbContext = new raw2Context()) { var entity = await dbContext.Set <TEntity>().FindAsync(id); if (entity == null) { return(false); } dbContext.Set <TEntity>().Remove(entity); await dbContext.SaveChangesAsync(); return(true); } }