

namespace Repository;

public class BankOperationRepository : RepositoryBase<BankOperation>, IBankOperationRepository
{
	public BankOperationRepository(RepositoryContext repositoryContext)
		:base(repositoryContext)
	{

	}

	public IQueryable<BankOperation> GetAll()
	{
		return FindAll().OrderBy(x => x.DocDate);
	}

	public IQueryable<BankOperation> GetAllConfirmed(Guid accountId, Guid businessId)
	{
		if (accountId == Guid.Empty)
			return FindByCondition(x => x.Status == "CONFIRMED");
		return FindByCondition(x => x.Status == "CONFIRMED" && x.BankAccountId == accountId && x.BusinessId == businessId);
	}

	public IQueryable<BankOperation> GetAllNew(Guid accountId, Guid businessId)
	{
		if(accountId == Guid.Empty)
			return FindByCondition(x => x.Status == "NEW");
		return FindByCondition(x => x.Status == "NEW" && x.BankAccountId == accountId && x.BusinessId == businessId);

	}

	public IQueryable<BankOperation> GetByBankAccountId(Guid bankAccountId)
	{
		return FindByCondition(x => x.BankAccountId == bankAccountId);
	}
}

