예제 #1
0
        public async Task <IHttpActionResult> ObterCliente(string idCliente)
        {
            try
            {
                var result = await _clienteApplication.ObterCliente(idCliente);

                if (result == null)
                {
                    return(StatusCode(HttpStatusCode.NoContent));
                }
                else
                {
                    return(Ok(result));
                }
            }
            catch (ApplicationException ex)
            {
                return(new BusinessResult(ex.Message, HttpStatusCode.BadRequest));
            }

            catch (Exception ex)
            {
                return(new BusinessResult(ex.Message, HttpStatusCode.InternalServerError));
            }
        }
예제 #2
0
 public JsonResult ListarClientes(int idCliente)
 {
     try
     {
         var cliente = _cliente.ObterCliente(idCliente).Result;
         if (cliente != null)
         {
             var result = new JsonResult(cliente);
             result.StatusCode = StatusCodes.Status200OK;
             return(result);
         }
         else
         {
             return(new JsonResult(StatusCode(StatusCodes.Status200OK, "Dados não localizados")));
         }
     }
     catch (Exception)
     {
         return(new JsonResult(StatusCode(StatusCodes.Status400BadRequest, "Erro inesperado")));
     }
 }