public async Task <IEnumerable <CatalogItemDto> > Handle(CatalogItemsQuery request, CancellationToken cancellationToken) { if (!request.IsValid()) { return(null); //TODO: return a bad request to be more clear to user } var idsToSelect = request.Ids.Select(id => Guid.Parse(id)); var items = await _catalogItemRepository.GetAll() .Select(c => new CatalogItemDto(c)) .Where(c => idsToSelect.Contains(c.Id)) .ToListAsync(cancellationToken); return(items); }
public async Task <IActionResult> ItemsAsync([FromBody] CatalogItemsQuery catalogItemsQuery) { return(Ok(await _mediator.Send(catalogItemsQuery))); }