public JsonResult SaveOrUpdateUserInfo(String code, String nickName, String gender) { String openid = GetOpenid(code); if (openid == "-1") { return(Json("获取openid失败!")); } T_UserDAO dao = new T_UserDAO(); T_User user = dao.getByOpenid(openid); if (user == null) { user = new T_User(); user.name = nickName; user.sex = int.Parse(gender); user.openid = openid; dao.Add(user); user = dao.getByOpenid(openid); } else { user.name = nickName; user.sex = int.Parse(gender); dao.Update(user); } return(Json(user.id)); }
[ValidateInput(false)] //要加上这一句,否则会造成富文本里面的HTML代码危险警报 public JsonResult Add(T_User entity) { if (entityDao.Add(entity) > 0) { return(Success("新增成功!", null)); } else { return(Fail("新增失败!")); } }