/// <summary>
        /// Gets the transaction by search.
        /// </summary>
        /// <param name="searchValue">The search value.</param>
        /// <returns></returns>
        public IQueryable <FinancialTransaction> Get(TransactionSearchValue searchValue)
        {
            var transactions = Repository.AsQueryable();

            if (searchValue.AmountRange.From.HasValue)
            {
                transactions = transactions.Where(transaction => transaction.Amount >= searchValue.AmountRange.From);
            }
            if (searchValue.AmountRange.To.HasValue)
            {
                transactions = transactions.Where(transaction => transaction.Amount <= searchValue.AmountRange.To);
            }
            if (searchValue.CreditCardTypeValueId.HasValue)
            {
                transactions = transactions.Where(transaction => transaction.CreditCardTypeValue.Id == searchValue.CreditCardTypeValueId.Value);
            }
            if (searchValue.CurrencyTypeValueId.HasValue)
            {
                transactions = transactions.Where(transaction => transaction.CurrencyTypeValue.Id == searchValue.CurrencyTypeValueId.Value);
            }
            if (searchValue.DateRange.From.HasValue)
            {
                transactions = transactions.Where(transaction => transaction.TransactionDateTime >= searchValue.DateRange.From.Value);
            }
            if (searchValue.DateRange.To.HasValue)
            {
                transactions = transactions.Where(transaction => transaction.TransactionDateTime <= searchValue.DateRange.To.Value);
            }
            if (searchValue.FundId.HasValue)
            {
                transactions = transactions.Where(transaction => transaction.TransactionFunds.Any(transactionFund => transactionFund.Fund.Id == searchValue.FundId.Value));
            }
            if (searchValue.SourceTypeValueId.HasValue)
            {
                transactions = transactions.Where(transaction => transaction.SourceTypeValueId == searchValue.SourceTypeValueId.Value);
            }
            if (!String.IsNullOrEmpty(searchValue.TransactionCode))
            {
                transactions = transactions.Where(transaction => transaction.TransactionCode == searchValue.TransactionCode);
            }
            return(transactions);
        }
示例#2
0
        private TransactionSearchValue GetSearchValue()
        {
            TransactionSearchValue searchValue = new TransactionSearchValue();

            decimal? fromAmountRange = null;
            if ( !String.IsNullOrEmpty( txtFromAmount.Text ) )
            {
                fromAmountRange = Decimal.Parse( txtFromAmount.Text );
            }
            decimal? toAmountRange = null;
            if ( !String.IsNullOrEmpty( txtToAmount.Text ) )
            {
                toAmountRange = Decimal.Parse( txtToAmount.Text );
            }
            searchValue.AmountRange = new RangeValue<decimal?>( fromAmountRange, toAmountRange );
            if ( ddlCreditCardType.SelectedValue != All.Id.ToString() )
            {
                searchValue.CreditCardTypeValueId = int.Parse( ddlCreditCardType.SelectedValue );
            }
            if ( ddlCurrencyType.SelectedValue != All.Id.ToString() )
            {
                searchValue.CurrencyTypeValueId = int.Parse( ddlCurrencyType.SelectedValue );
            }
            DateTime? fromTransactionDate = dtStartDate.SelectedDate;
            DateTime? toTransactionDate = dtEndDate.SelectedDate;
            searchValue.DateRange = new RangeValue<DateTime?>( fromTransactionDate, toTransactionDate );
            if ( ddlFundType.SelectedValue != "-1" )
            {
                searchValue.FundId = int.Parse( ddlFundType.SelectedValue );
            }
            searchValue.TransactionCode = txtTransactionCode.Text;
            searchValue.SourceTypeValueId = int.Parse( ddlSourceType.SelectedValue );

            return searchValue;
        }