public async Task <IActionResult> GetArchives([FromQuery] ListProducerQuery query) { if (!ModelState.IsValid) { return(BadRequest()); } var result = await _producerService.ListArchivesAsync(query); return(Ok(result.ToResponseDto())); }
public async Task <PageListDto <ProducerBasicDto> > ListArchivesAsync(ListProducerQuery query) { if (query.ShouldSearch()) { return(await _context.Producers .Where(x => x.IsArchival && query.SearchBy.Any(y => x.Name.ToLower().Contains(y.ToLower()))) .ProjectTo <ProducerBasicDto>() .OrderBy(x => x.Name) .ToPagedListAsync(query)); } return(await _context.Producers .Where(x => x.IsArchival) .ProjectTo <ProducerBasicDto>() .OrderBy(x => x.Name) .ToPagedListAsync(query)); }