public ActionResult <IEnumerable <FindProductResponse> > FindProduct([FromQuery] FindProductQuery request) { try { var response = _mediator.Send(request); return(Ok(response.Result)); } catch (Exception e) { _logger.LogInformation(e.Message); return(BadRequest(e.Message)); } }
public IActionResult FindProduct([FromBody] FindProductModel model) { try { var query = new FindProductQuery(model.ArticuleId); var result = _queryProcessor.Process(query); return(new OkObjectResult(result)); } catch (AppException ex) { return(BadRequest(ex.Message)); } }
public async Task <ActionResult <GetProductByIdResultModel> > Get(int productId, CancellationToken cancellationToken = default) { try { var query = new FindProductQuery(productId); var response = await queryBus.Dispatch <FindProductQuery, FindProductQueryResult>(query, cancellationToken).ConfigureAwait(false); return(Ok(mapper.Map <GetProductByIdResultModel>(response))); } catch (Exception ex) { return(BadRequest(ex.Message)); } }