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()); }
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); }
public async Task <ActionResult <List <TransactionDto> > > SearchByData(SearchTransactionQuery query) { return(Ok(await Mediator.Send(query))); }
public async Task <TransactionDto[]> Search(SearchTransactionQuery query) { var transactions = await _unitOfWork.Transactions.Search(query); return(transactions.Select(ToDto).ToArray()); }