public HttpResponseMessage UpdateUser(QM_INFRA_SAMPLING_RULE user) { try { ruleBO.UpdateSome(user); return(Request.CreateResponse(HttpStatusCode.OK, "更新成功")); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "更新出错:" + ex.Message)); } }
public HttpResponseMessage AddUser(QM_INFRA_SAMPLING_RULE Rule) { IList <QM_INFRA_SAMPLING_RULE> list = new List <QM_INFRA_SAMPLING_RULE>(); list = ruleBO.GetAll(); //log.Debug(JsonConvert.SerializeObject(list)); for (int i = 0; i < list.Count; i++) { if (Rule.ExamType == list[i].ExamType)//如果类型相同则对比 { if (Rule.LowerBound < list[i].UpperBound && Rule.LowerBound >= list[i].LowerBound) { //return Request.CreateResponse(HttpStatusCode.InternalServerError, "下限值输入有误!"); return(Request.CreateResponse(HttpStatusCode.OK, "下限值输入有误!")); } if (Rule.UpperBound <= list[i].UpperBound && Rule.UpperBound > list[i].LowerBound) { //return Request.CreateResponse(HttpStatusCode.InternalServerError, "上限值输入有误!"); return(Request.CreateResponse(HttpStatusCode.OK, "上限值输入有误!")); } } } Rule.creation_date = DateTime.Now; QM_INFRA_SAMPLING_RULE newRule = this.ruleBO.Insert(Rule); if (newRule != null) { return(Request.CreateResponse(HttpStatusCode.OK, "新增成功")); } else { return(Request.CreateResponse(HttpStatusCode.InternalServerError, "新增失败")); } }