public HttpResponseMessage UpdateUser([FromBody] User user) { try { bool result = UserPL.Update(user); return(result.Equals(true) ? Request.CreateResponse(HttpStatusCode.OK, "User Updated Successfully.") : Request.CreateResponse(HttpStatusCode.BadRequest, "Failed")); } catch (Exception ex) { ErrorHandler.WriteError(ex); var response = Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message); return(response); } }
public HttpResponseMessage UpdateUser([FromBody] User user) { try { if (ModelState.IsValid) { bool result = UserPL.Update(user); return(result.Equals(true) ? Request.CreateResponse(HttpStatusCode.OK, "User Updated Successfully.") : Request.CreateResponse(HttpStatusCode.BadRequest, "Failed")); } else { string errors = ModelStateValidation.GetErrorListFromModelState(ModelState); return(Request.CreateResponse(HttpStatusCode.BadRequest, errors)); } } catch (Exception ex) { ErrorHandler.WriteError(ex); var response = Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message); return(response); } }