Fixed bugs

This commit is contained in:
2020-09-26 20:49:09 +02:00
parent b21781edde
commit 1811ea5a1a
7 changed files with 38 additions and 14 deletions

View File

@ -27,7 +27,7 @@ namespace UserService.DatabaseLayer.Repositories
await db.SaveChangesAsync(token).ConfigureAwait(false);
}
public async Task DeleteAsync(T entity, CancellationToken token = default)
public virtual async Task DeleteAsync(T entity, CancellationToken token = default)
{
await using var db = new UserServiceDbContext();
Context(db).Remove(entity);
@ -45,7 +45,7 @@ namespace UserService.DatabaseLayer.Repositories
await using var db = new UserServiceDbContext();
return await Context(db).Include(x => x.Parent).FirstOrDefaultAsync(predicate, token).ConfigureAwait(false);
}
public async Task<bool> UpdateAsync(T entity, CancellationToken token = default)
public virtual async Task<bool> UpdateAsync(T entity, CancellationToken token = default)
{
await using var db = new UserServiceDbContext();
Context(db).Update(entity);

View File

@ -22,6 +22,7 @@ namespace UserService.DatabaseLayer.Repositories
return await Context(db)
.Include(x => x.Parent)
.Include(x => x.Members)
.ThenInclude(x=> x.AttachedMember)
.WhereOrDefault(predicate)
.ToListAsync(token).ConfigureAwait(false);
}
@ -32,7 +33,16 @@ namespace UserService.DatabaseLayer.Repositories
return await Context(db)
.Include(x => x.Parent)
.Include(x => x.Members)
.ThenInclude(x=> x.AttachedMember)
.FirstOrDefaultAsync(predicate, token).ConfigureAwait(false);
}
public override async Task<bool> UpdateAsync(SecurityGroup entity, CancellationToken token = default)
{
await using var db = new UserServiceDbContext();
Context(db).Update(entity);
var items = await db.SaveChangesAsync(token).ConfigureAwait(false);
return items > 0;
}
}
}