namespace MyOffice.Data.Repositories.Account; using Microsoft.EntityFrameworkCore; using Models.Accounts; using MyOffice.DbContext; public class AccountAccountCategoryRepository : AppRepository, IAccountAccountCategoryRepository { public AccountAccountCategoryRepository(AppDbContext context) : base(context) { } public List Get(Guid userId, Guid accountId, Guid categoryId) { return _context.AccountAccountCategories .Include(x => x.Account) .Include(x => x.Category) .Where(x => x.AccountId == accountId && x.CategoryId == categoryId && x.Category.UserId == userId) .ToList(); } public async Task> GetAsync( Guid userId, Guid accountId, Guid categoryId, CancellationToken cancellationToken = default ) { return await _context.AccountAccountCategories .Include(x => x.Account) .Include(x => x.Category) .Where(x => x.AccountId == accountId && x.CategoryId == categoryId && x.Category.UserId == userId) .ToListAsync(cancellationToken); } public bool Remove(AccountAccountCategory accountAccountCategory) { return RemoveBase(accountAccountCategory) > 0; } public async Task RemoveAsync(AccountAccountCategory accountAccountCategory, CancellationToken cancellationToken = default) { return await RemoveBaseAsync(accountAccountCategory, cancellationToken) > 0; } public bool Add(AccountAccountCategory accountAccountCategory) { return AddBase(accountAccountCategory) > 0; } public async Task AddAsync(AccountAccountCategory accountAccountCategory, CancellationToken cancellationToken = default) { return await AddBaseAsync(accountAccountCategory, cancellationToken) > 0; } }