little modifications to users
This commit is contained in:
@ -52,7 +52,7 @@ namespace UserService.DatabaseLayer.DataModels
|
||||
public Node? Parent { get; set; } //Parent
|
||||
public int? ParentId { get; set; }
|
||||
|
||||
public override string ToString() => $"[{GetType().Name}] {Id:D5} {CommonName}";
|
||||
public override string ToString() => CommonName;
|
||||
|
||||
public int Level => Parent?.Level + 1 ?? 0;
|
||||
|
||||
|
@ -38,11 +38,12 @@ namespace UserService.DatabaseLayer.Repository
|
||||
await db.SaveChangesAsync(token);
|
||||
}
|
||||
|
||||
public async Task UpdateAsync(T entity, CancellationToken token = default)
|
||||
public async Task<bool> UpdateAsync(T entity, CancellationToken token = default)
|
||||
{
|
||||
await using var db = new UserServiceDbContext();
|
||||
Context(db).Update(entity);
|
||||
await db.SaveChangesAsync(token);
|
||||
var items= await db.SaveChangesAsync(token);
|
||||
return items > 0;
|
||||
}
|
||||
|
||||
public async Task DeleteAsync(T entity, CancellationToken token = default)
|
||||
|
@ -13,7 +13,7 @@ namespace UserService.DatabaseLayer.Repository
|
||||
Task<IReadOnlyList<T>> GetAllAsync(Expression<Func<T, bool>>? predicate = null, CancellationToken token = default);
|
||||
Task<T?> GetAsync(Expression<Func<T, bool>> predicate, CancellationToken token = default);
|
||||
Task AddAsync(T entity, CancellationToken token = default);
|
||||
Task UpdateAsync(T entity, CancellationToken token = default);
|
||||
Task<bool> UpdateAsync(T entity, CancellationToken token = default);
|
||||
Task DeleteAsync(T entity, CancellationToken token = default);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user