示例#1
0
        public IActionResult ValidarPedido(
            [FromServices] ICreateStatusHandler handler,
            [FromBody] CreateStatusRequest command)
        {
            try
            {
                var pedido = _pedidoService.GetAllSolicitacaoByIdAsync(command.Pedido);

                if (pedido.Result == null)
                {
                    List <string> statusList = new List <string>();
                    statusList.Add("CODIGO_PEDIDO_INVALIDO");
                    return(NotFound(new CreateStatusResponse()
                    {
                        Status = statusList
                    }));
                }


                var retorno = handler.Handle(command, pedido.Result);
                return(Ok(retorno));
            }
            catch (Exception ex)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError,
                                       $"Erro ao tentar verificar status. Erro: {ex.Message}"));
            }
        }
        public async Task <IActionResult> GetByIdAsync(int id)
        {
            try
            {
                var solicitacao = await _solicitacaoService.GetAllSolicitacaoByIdAsync(id);

                if (solicitacao == null)
                {
                    return(NotFound("Solicitacaoção de pedido por Id não encontrado!"));
                }

                return(Ok(solicitacao));
            }
            catch (Exception ex)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError,
                                       $"Erro ao tentar recuperar solicitação de pedido. Erro: {ex.Message}"));
            }
        }