public Task <IEnumerable <MfAggrTransaction> > GetLastOneAsync(MfAggrTransactionSearch option, CancellationToken token = default(CancellationToken))
        {
            var query = @"
SELECT      TOP 1 tr.*
FROM        [dbo].[MfAggrTransaction] tr
WHERE       tr.[CompanyId]     = @CompanyId";

            if (option.CurrencyId.HasValue)
            {
                query += @"
AND         tr.[CurrencyId]    = @CurrencyId";
            }
            query += @"
ORDER BY    tr.[CreateAt]        DESC
";
            return(dbHelper.GetItemsAsync <MfAggrTransaction>(query, option, token));
        }
Beispiel #2
0
 public Task <IEnumerable <MfAggrTransaction> > GetLastOneAsync(MfAggrTransactionSearch option, CancellationToken token = default(CancellationToken))
 => mfAggrTransactionQueryProcessor.GetLastOneAsync(option, token);
 public async Task <MfAggrTransaction> GetLastOne(MfAggrTransactionSearch option, CancellationToken token)
 => (await mfAggrTransactionProcessor.GetLastOneAsync(option, token)).FirstOrDefault();
 public async Task <MfAggrTransaction[]> Get(MfAggrTransactionSearch option, CancellationToken token)
 => (await mfAggrTransactionProcessor.GetAsync(option, token)).ToArray();
        public Task <IEnumerable <MfAggrTransaction> > GetAsync(MfAggrTransactionSearch option, CancellationToken token = default(CancellationToken))
        {
            var query = @"
SELECT        tr.*
            , ac.[DisplayName]      [AccountName]
            , sb.[Name]             [SubAccountName]
            , sb.[AccountTypeName]
            , sb.[AccountNumber]
FROM        [dbo].[MfAggrTransaction] tr
INNER JOIN  [dbo].[MfAggrAccount] ac
ON          ac.[Id]                 = tr.[AccountId]
INNER JOIN  [dbo].[MfAggrSubAccount] sb
ON          sb.[Id]                 = tr.[SubAccountId]
LEFT JOIN   [dbo].[BankAccountType] at
ON          at.[Id]                 = sb.[AccountTypeId]
WHERE       tr.[CompanyId]          = @CompanyId";

            if (option.CurrencyId.HasValue)
            {
                query += @"
AND         tr.[CurrencyId]         = @CurrencyId";
            }
            if (option.RecordedAtFrom.HasValue)
            {
                query += @"
AND         tr.[RecordedAt]        >= @RecordedAtFrom";
            }
            if (option.RecordedAtTo.HasValue)
            {
                query += @"
AND         tr.[RecordedAt]        <= @RecordedAtTo";
            }
            if (!string.IsNullOrEmpty(option.AccountName))
            {
                option.AccountName = Sql.GetWrappedValue(option.AccountName);
                query += @"
AND         ac.[DisplayName]     LIKE @AccountName";
            }
            if (!string.IsNullOrEmpty(option.SubAccountName))
            {
                option.SubAccountName = Sql.GetWrappedValue(option.SubAccountName);
                query += @"
AND         sb.[Name]            LIKE @SubAccountName";
            }
            if (!string.IsNullOrEmpty(option.BankCode))
            {
                query += @"
AND         ac.[BankCode]           = @BankCode";
            }
            if (!string.IsNullOrEmpty(option.BranchCode))
            {
                query += @"
AND         sb.[BranchCode]         = @BranchCode";
            }
            if (!string.IsNullOrEmpty(option.AccountTypeName))
            {
                option.AccountTypeName = Sql.GetWrappedValue(option.AccountTypeName);
                query += @"
AND         sb.[AccountTypeName] LIKE @AccountTypeName";
            }
            if (option.AccountTypeId.HasValue)
            {
                query += @"
AND         sb.[AccountTypeId]      = @AccountTypeId";
            }
            if (!string.IsNullOrEmpty(option.AccountNumber))
            {
                query += @"
AND         sb.[AccountNumber]      = @AccountNumber";
            }
            query += @"
ORDER BY    tr.[Id]        ASC
";
            return(dbHelper.GetItemsAsync <MfAggrTransaction>(query, option, token));
        }