Exemple #1
0
        public async Task <IActionResult> ProcurarPorID([FromQuery] UsuarioPorID request)
        {
            try
            {
                var response = await _mediator.Send(request, CancellationToken.None);

                return(await ResponseQuerieAsync(response));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
        public async Task <ResponseQueries> Handle(UsuarioPorID request, CancellationToken cancellationToken)
        {
            if (request == null)
            {
                return(new ResponseQueries(false, "Informe o ID do usuário", null));
            }

            var usuario = await _consultaUsuario.ProcurarPorID(request.Id);

            if (usuario == null)
            {
                return(new ResponseQueries(false, "Nenhum usuário encontrado com o ID: " + request.Id, null));
            }

            return(await ResponseHandlerBase.RetornoDaConsulta(true, "Usuarios", usuario));
        }