Added FxCop and get Organization Unit selection running
This commit is contained in:
@ -12,7 +12,7 @@ namespace UserService.DatabaseLayer.Repository
|
||||
{
|
||||
public class BaseRepository<T> where T : Node
|
||||
{
|
||||
protected readonly Func<UserServiceDbContext, DbSet<T>> Context;
|
||||
protected Func<UserServiceDbContext, DbSet<T>> Context { get; }
|
||||
|
||||
protected BaseRepository(Func<UserServiceDbContext, DbSet<T>> context)
|
||||
{
|
||||
@ -22,27 +22,27 @@ namespace UserService.DatabaseLayer.Repository
|
||||
public virtual async Task<IReadOnlyList<T>> GetAllAsync(Expression<Func<T, bool>>? predicate = null, CancellationToken token = default)
|
||||
{
|
||||
await using var db = new UserServiceDbContext();
|
||||
return await Context(db).Include(x => x.Parent).WhereOrDefault(predicate).ToListAsync(token);
|
||||
return await Context(db).Include(x => x.Parent).WhereOrDefault(predicate).ToListAsync(token).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<T?> GetAsync(Expression<Func<T, bool>> predicate, CancellationToken token = default)
|
||||
{
|
||||
await using var db = new UserServiceDbContext();
|
||||
return await Context(db).FirstOrDefaultAsync(predicate, token);
|
||||
return await Context(db).FirstOrDefaultAsync(predicate, token).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task AddAsync(T entity, CancellationToken token = default)
|
||||
{
|
||||
await using var db = new UserServiceDbContext();
|
||||
await Context(db).AddAsync(@entity, token);
|
||||
await db.SaveChangesAsync(token);
|
||||
await Context(db).AddAsync(@entity, token).ConfigureAwait(false);
|
||||
await db.SaveChangesAsync(token).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<bool> UpdateAsync(T entity, CancellationToken token = default)
|
||||
{
|
||||
await using var db = new UserServiceDbContext();
|
||||
Context(db).Update(entity);
|
||||
var items= await db.SaveChangesAsync(token);
|
||||
var items= await db.SaveChangesAsync(token).ConfigureAwait(false);
|
||||
return items > 0;
|
||||
}
|
||||
|
||||
@ -50,7 +50,7 @@ namespace UserService.DatabaseLayer.Repository
|
||||
{
|
||||
await using var db = new UserServiceDbContext();
|
||||
Context(db).Remove(entity);
|
||||
await db.SaveChangesAsync(token);
|
||||
await db.SaveChangesAsync(token).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
@ -24,7 +24,7 @@ namespace UserService.DatabaseLayer.Repository
|
||||
var rootOus = await Context(db)
|
||||
.Include(x => x.Parent)
|
||||
.WhereOrDefault(predicate)
|
||||
.ToListAsync(cancellationToken: token);
|
||||
.ToListAsync(cancellationToken: token).ConfigureAwait(false);
|
||||
|
||||
IEnumerable<OrganizationUnit> Rec(Node node)
|
||||
{
|
||||
|
Reference in New Issue
Block a user