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)); } }
public async Task <IActionResult> Get(int id) { try { return(Ok(await _usuarioApp.Get(id))); } catch (ValidationException valEx) { return(BadRequest(new ErroGenerico { Mensagem = valEx.Message })); } }