Ejemplo n.º 1
0
        public ActionResult Index(int?idUsuario)
        {
            try
            {
                ViewBag.NomeUsuario     = UsuarioLogado.Nome;
                ViewBag.IsUsuarioLogado = !idUsuario.HasValue || idUsuario == UsuarioLogado.Id;

                if (!idUsuario.HasValue || idUsuario == UsuarioLogado.Id)
                {
                    return(View("Index", UsuarioLogado));
                }

                var response = _usuarioApp.Get((int)idUsuario);
                if (!response.IsSuccessStatusCode)
                {
                    return(ErrorMessage(response.Content.ReadAsStringAsync().Result));
                }

                var usuario = JsonConvert.DeserializeObject <Models.Entity.Usuario>(response.Content.ReadAsStringAsync().Result);
                return(View("Index", usuario));
            }
            catch (Exception ex)
            {
                return(ErrorMessage(ex.Message));
            }
        }
Ejemplo n.º 2
0
 public async Task <IActionResult> Get(int id)
 {
     try
     {
         return(Ok(await _usuarioApp.Get(id)));
     }
     catch (ValidationException valEx)
     {
         return(BadRequest(new ErroGenerico {
             Mensagem = valEx.Message
         }));
     }
 }