public HttpResponseMessage Post([FromBody] CarInfo model) { var wemodel = new WeChatUser() { CarId = model.Id, OpenId = model.OpenId }; var count = 0; if (string.IsNullOrEmpty(model.Id)) { model.Id = Guid.NewGuid().ToString(); wemodel.CarId = model.Id; count = CarInfoDappler.Add(model); //添加完后 用户绑定信息id if (count == 1) { WechatDappler.Update("update wechatUser set carId = @carId where openId=@openId", wemodel); } } else { count = CarInfoDappler.Update(model); } //判断是否所以信息都已填写 Type t = model.GetType(); PropertyInfo[] PropertyList = t.GetProperties(); var b = true; foreach (PropertyInfo item in PropertyList) { string name = item.Name; object value = item.GetValue(model); if (value != null) { if (value.ToString() != "") { continue; } } b = false; break; } if (b) { WechatDappler.Update("update wechatUser set status = 1 where openId=@openId", wemodel); } HttpResponseMessage result = Request.CreateResponse(HttpStatusCode.OK, new { status = "OK", data = count == 1 }, Configuration.Formatters.JsonFormatter); return(result); }