little modifications to users

This commit is contained in:
2020-08-06 22:57:25 +02:00
parent 07f466d74b
commit d58a8702b3
11 changed files with 74 additions and 28 deletions

View File

@ -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;

View File

@ -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)

View File

@ -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);
}