Files
myoffice/MyOffice.Data.Repositories/Account/AccountCategoryRepository.cs
T
2023-06-17 14:16:09 +03:00

38 lines
900 B
C#

namespace MyOffice.Data.Repositories.Account;
using Microsoft.EntityFrameworkCore;
using Models.Accounts;
using MyOffice.Data.Repositories;
public class AccountCategoryRepository : AppRepository<AccountCategory>, IAccountCategoryRepository
{
public List<AccountCategory> GetAll(Guid userId)
{
return _context.AccountCategories
.Include(x => x.Accounts)
.Where(x => x.UserId == userId)
.ToList();
}
public bool Add(AccountCategory accountCategory)
{
return AddBase(accountCategory) > 0;
}
public AccountCategory? Get(Guid userId, Guid id)
{
return _context.AccountCategories
.Include(x => x.Accounts)
.FirstOrDefault(x => x.Id == id && x.UserId == userId);
}
public bool Update(AccountCategory accountCategory)
{
return UpdateBase(accountCategory) > 0;
}
public bool Remove(AccountCategory accountCategory)
{
return RemoveBase(accountCategory) > 0;
}
}