public ActionResult AddUser(PlatformUserModel model) { JsonModel jm = new JsonModel(); //如果表单模型验证成功 if (ModelState.IsValid) { IPlatformUserBLL platformUserBll = BLLFactory <IPlatformUserBLL> .GetBLL("PlatformUserBLL"); T_PlatformUser platformUser = new T_PlatformUser() { UserName = model.UserName, TrueName = model.TrueName, Password = PropertyUtils.GetMD5Str(model.Password), Memo = model.Memo, Tel = model.Tel, Phone = model.Phone, Email = model.Email }; // 保存到数据库 platformUserBll.Save(platformUser); //日志记录 jm.Content = PropertyUtils.ModelToJsonString(model); } else { // 保存异常日志 jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR; } return(Json(jm, JsonRequestBehavior.AllowGet)); }
public ActionResult EditUser(int?id) { // 参数校验 if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } IPlatformUserBLL platformUserBll = BLLFactory <IPlatformUserBLL> .GetBLL("PlatformUserBLL"); var userInfo = platformUserBll.GetEntity(index => index.Id == id && index.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); if (userInfo != null) { PlatformUserModel platformUserModel = new PlatformUserModel(); platformUserModel.UserId = userInfo.Id; platformUserModel.UserName = userInfo.UserName; platformUserModel.TrueName = userInfo.TrueName; platformUserModel.Memo = userInfo.Memo; platformUserModel.Tel = userInfo.Tel; platformUserModel.Phone = userInfo.Phone; platformUserModel.Email = userInfo.Email; platformUserModel.HeadPath = userInfo.HeadPath; return(View(platformUserModel)); } else { return(RedirectToAction("UserList")); } }
public ActionResult EditUser(PlatformUserModel model) { JsonModel jm = new JsonModel(); //如果表单模型验证成功 if (ModelState.IsValid) { IPlatformUserBLL platformUserBll = BLLFactory <IPlatformUserBLL> .GetBLL("PlatformUserBLL"); T_PlatformUser platformUser = platformUserBll.GetEntity(m => m.Id == model.UserId && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); if (platformUser != null) { platformUser.UserName = model.UserName; platformUser.TrueName = model.TrueName; platformUser.Memo = model.Memo; platformUser.Tel = model.Tel; platformUser.Phone = model.Phone; platformUser.Email = model.Email; // 保存到数据库 platformUserBll.Update(platformUser); //日志记录 jm.Content = PropertyUtils.ModelToJsonString(model); } else { jm.Msg = "该用户不存在"; } } else { // 保存异常日志 jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR; } return(Json(jm, JsonRequestBehavior.AllowGet)); }
public ActionResult UploadPic(int id) { JsonModel jm = new JsonModel(); IPlatformUserBLL UserBll = BLLFactory <IPlatformUserBLL> .GetBLL("PlatformUserBLL"); var user = UserBll.GetEntity(m => m.DelFlag == 0 && m.Id == id); //用户存在 if (user != null) { PlatformUserModel userModel = new PlatformUserModel() { UserId = user.Id, HeadPath = user.HeadPath }; return(View(userModel)); } //用户不存在 else { jm.Msg = "用户不存在"; } return(Json(jm, JsonRequestBehavior.AllowGet)); }