public async Task <IActionResult> GetArchives([FromQuery] ListOrderQuery query) { if (!ModelState.IsValid) { return(BadRequest()); } var result = await _orderService.ListArchivesAsync(query); return(Ok(result.ToResponseDto())); }
public async Task <PageListDto <OrderBasicDto> > ListArchivesAsync(ListOrderQuery query) { if (query.ShouldSearch()) { return(await _context.Orders .Where(x => x.UserId == query.UserId && x.IsArchival && (query.SearchBy.Any(y => x.Description.ToLower().Contains(y.ToLower())) )) .ProjectTo <OrderBasicDto>() .OrderByDescending(x => x.Date) .ToPagedListAsync(query)); } return(await _context.Orders .Where(x => x.UserId == query.UserId && x.IsArchival) .ProjectTo <OrderBasicDto>() .OrderByDescending(x => x.Date) .ToPagedListAsync(query)); }
public IEnumerable <OrderViewModel> All() { var query = new ListOrderQuery(_orderRepository); return(query.Query().Select(o => o.Adapt <OrderViewModel>())); }