コード例 #1
0
        public async Task <Domain.Transaction[]> Search(SearchTransactionQuery searchOptions)
        {
            var querybleEntities = _context.Transactions.AsQueryable <TransactionEntity>();

            if (!string.IsNullOrEmpty(searchOptions.Currency))
            {
                querybleEntities = querybleEntities.Where(x => x.Currency == searchOptions.Currency);
            }
            if (searchOptions.DateEnd.HasValue)
            {
                querybleEntities = querybleEntities.Where(x => x.Date <= searchOptions.DateEnd.Value);
            }
            if (searchOptions.DateStart.HasValue)
            {
                querybleEntities = querybleEntities.Where(x => x.Date >= searchOptions.DateStart.Value);
            }
            if (searchOptions.Status.HasValue)
            {
                querybleEntities = querybleEntities.Where(x => x.Status >= searchOptions.Status.Value);
            }

            var entities = await querybleEntities.ToListAsync();

            return(entities.Select(ToDomainModel).ToArray());
        }
コード例 #2
0
ファイル: SearchByData.cs プロジェクト: PinsChomchanphan/Exam
        public async Task SearchByDataReturnsTransactionDtoList()
        {
            var client = _factory.GetAnonymousClient();

            var sq = new SearchTransactionQuery()
            {
                CurrencyCode = "",
                Status       = "",
                StartDate    = null,
                DueDate      = null
            };
            var content  = Utilities.GetRequestContent(sq);
            var response = await client.PostAsync("/api/transaction/search", content);

            response.EnsureSuccessStatusCode();

            var vm = await Utilities.GetResponseContent <List <TransactionDto> >(response);

            Assert.IsType <List <TransactionDto> >(vm);
        }
コード例 #3
0
 public async Task <ActionResult <List <TransactionDto> > > SearchByData(SearchTransactionQuery query)
 {
     return(Ok(await Mediator.Send(query)));
 }
コード例 #4
0
        public async Task <TransactionDto[]> Search(SearchTransactionQuery query)
        {
            var transactions = await _unitOfWork.Transactions.Search(query);

            return(transactions.Select(ToDto).ToArray());
        }