Beispiel #1
0
        public HttpResponseMessage Cadastrar(User user)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var social = new Social();
                    var result = social.CriarUsuario(user);

                    if (result != null)
                    {
                        return(Request.CreateResponse(HttpStatusCode.Created, new UserDto(user.Obter(result.id))));
                    }
                    return(Request.CreateErrorResponse(HttpStatusCode.PreconditionFailed, "Usuário existente"));
                }
                return(Request.CreateErrorResponse(HttpStatusCode.PreconditionFailed, "Campos incorretos."));
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex));
            }
        }