Cleanup
This commit is contained in:
@ -37,13 +37,20 @@ namespace UserService.DatabaseLayer.Repositories
|
||||
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).ConfigureAwait(false);
|
||||
return await Context(db)
|
||||
.Include(x => x.Parent)
|
||||
.WhereOrDefault(predicate)
|
||||
.ToListAsync(token)
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public virtual async Task<T?> GetAsync(Expression<Func<T, bool>> predicate, CancellationToken token = default)
|
||||
{
|
||||
await using var db = new UserServiceDbContext();
|
||||
return await Context(db).Include(x => x.Parent).FirstOrDefaultAsync(predicate, token).ConfigureAwait(false);
|
||||
return await Context(db)
|
||||
.Include(x => x.Parent)
|
||||
.FirstOrDefaultAsync(predicate, token)
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
public virtual async Task<bool> UpdateAsync(T entity, CancellationToken token = default)
|
||||
{
|
||||
|
@ -32,8 +32,10 @@ namespace UserService.DatabaseLayer.Repositories
|
||||
|
||||
}
|
||||
|
||||
public interface IMembersRepository : IRepository<Member>
|
||||
public interface IMembersRepository
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -24,7 +24,7 @@ namespace UserService.DatabaseLayer.Repositories
|
||||
var rootOus = await Context(db)
|
||||
.Include(x => x.Parent)
|
||||
.WhereOrDefault(predicate)
|
||||
.ToListAsync(cancellationToken: token).ConfigureAwait(false);
|
||||
.ToListAsync(token).ConfigureAwait(false);
|
||||
|
||||
IEnumerable<OrganizationUnit> Rec(Node node)
|
||||
{
|
||||
|
@ -1,4 +1,6 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
#nullable enable
|
||||
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -39,8 +41,11 @@ namespace UserService.DatabaseLayer.Repositories
|
||||
|
||||
public override async Task<bool> UpdateAsync(SecurityGroup entity, CancellationToken token = default)
|
||||
{
|
||||
if (entity == null) throw new ArgumentNullException(nameof(entity));
|
||||
|
||||
await using var db = new UserServiceDbContext();
|
||||
Context(db).Update(entity);
|
||||
db.UserMembers.UpdateRange(entity.Members);
|
||||
var items = await db.SaveChangesAsync(token).ConfigureAwait(false);
|
||||
return items > 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user