Esempio n. 1
0
 public IHttpActionResult PutUser(string userId, [FromBody] User user)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     try
     {
         userValidator.secure(Request);
         userValidator.PutUser(userId, 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(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.OK, "OK")));
 }