public async Task <IEnumerable <object> > GetAllAsync(OrderQueryParamsDto queryParams) { var query = _orderRepo.GetAll() .Where(o => queryParams.IsBorrowed == null || queryParams.IsBorrowed == o.IsBorrowed) .Where(o => queryParams.Reader == null || o.Reader.Name.Contains(queryParams.Reader)) .Where(o => queryParams.Librarian == null || o.Librarian.Name.Contains(queryParams.Librarian)) .ProjectTo <OrderReadDto>(_mapper.ConfigurationProvider) .OrderByDynamic(queryParams.PropertyNameToOrder, queryParams.Ascending); if (!string.IsNullOrEmpty(queryParams.PropertyNameToGroup)) { return((await query .ToListAsync()) .GroupByDynamic(queryParams.PropertyNameToGroup)); } return(await query.ToListAsync()); }
public async Task <ActionResult <IEnumerable <object> > > GetAll([FromQuery] OrderQueryParamsDto queryParams) { return(Ok(await _orderService.GetAllAsync(queryParams))); }