コード例 #1
0
        public async Task <ActionResult <IEnumerable <Produto> > > GetProdutos()
        {
            try
            {
                var command  = new GetTodosProdutosQuery();
                var response = await _mediator.Send(command);

                return(Ok(response));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
コード例 #2
0
 public async Task <IEnumerable <Produto> > Handle(GetTodosProdutosQuery request, CancellationToken cancellationToken)
 {
     return(await _context.Produtos.ToListAsync());
 }