Exemplo n.º 1
0
 public IHttpActionResult PostUser(User user)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     try
     {
         //          userValidator.secure(Request);
         userValidator.PostUser(user);
     }
     catch (NotAdminException exception)
     {
         return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.BadRequest, exception.Mymessage)));
     }
     catch (NotExistException exception)
     {
         return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.BadRequest, exception.Mymessage)));
     }
     catch (System.Data.SqlClient.SqlException)
     {
         return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "VecinosUY no se puede conectar a la base de datos (∩︵∩)")));
     }
     catch (Exception exception)
     {
         return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exception.Message)));
     }
     return(Ok(user));
 }