This commit is contained in:
2023-12-01 20:47:42 +02:00
parent a09fc7ece3
commit 045f60e373
39 changed files with 1252 additions and 945 deletions
@@ -21,11 +21,15 @@ public class AccountRepository : AppRepository<Account>, IAccountRepository
{
return _context.Accounts!
.Include(x => x.CurrencyGlobal)
.Include(x => x.Categories!.Where(x => x.Category.UserId == userId))!
// categories created with current user
.Include(x => x.Categories!.Where(c => c.Category.UserId == userId))!
.ThenInclude(x => x.Category)
.Include(x => x.AccessRights)!
// access rights created with current user
.Include(x => x.AccessRights!.Where(a => a.OwnerId == userId))!
.ThenInclude(x => x.User)
.Include(x => x.Motions)!
// require only one motions to check if can to delete account
.Include(x => x.Motions!.Take(1))!
// only accounts with access to current user
.Where(x => x.AccessRights!.Any(a => a.UserId == userId))
.ToList();
}