예제 #1
0
        public IActionResult PostUsuario([FromBody] UsuarioView value)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest());
                }
                else
                {
                    UsuarioView userCadastrado = business.Incluir(value);

                    var uri = Url.Action("GetUsuarioPorId", new { id = userCadastrado.Id });
                    return(Created(uri, userCadastrado));
                }
            }
            catch (Exception ex)
            {
                return(StatusCode(500, new { Mensagem = ex.Message.ToString() }));
            }
        }