public HttpResponseMessage UpdateData(string id, [FromBody] preg_question dataUpdate) { try { int user_id = Convert.ToInt32(((ClaimsIdentity)(User.Identity)).FindFirst("id").Value); if (!dataUpdate.DeepEquals(new preg_question())) { preg_question question = new preg_question(); question = dao.GetItemByID(Convert.ToInt32(id)).Where(c => c.custom_question_by_user_id == null || c.custom_question_by_user_id == user_id).FirstOrDefault(); if (question == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, SysConst.DATA_NOT_FOUND)); } if (dataUpdate.question_type_id != null) { question.question_type_id = dataUpdate.question_type_id; } if (dataUpdate.content != null) { question.content = dataUpdate.content; } if (dataUpdate.custom_question_by_user_id != null) { question.custom_question_by_user_id = user_id; } dao.UpdateData(question); return(Request.CreateResponse(HttpStatusCode.Accepted, SysConst.DATA_UPDATE_SUCCESS)); } else { HttpError err = new HttpError(SysConst.DATA_NOT_EMPTY); return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, err)); } } catch (Exception ex) { HttpError err = new HttpError(ex.Message); return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, err)); } }