public ActionResult UserSave(UserInfo entity) { ViewBag.selectList = GetSelectList(); var ValidUser = UserInfoBz.IsExist(o => o.UserName == entity.UserName && o.ID != entity.ID); if (ValidUser) { ViewBag.Msg = $"该用户已存在:{entity.UserName}!"; return(View("UserEidt", entity)); } if (string.IsNullOrWhiteSpace(entity.UserName)) { ViewBag.Msg = $"用户名不能为空"; return(View("UserEidt", entity)); } if (entity.ID <= 0) { entity.Pwd = UserInfoBz.GetPwdAES("123456"); } var isSuccess = UserInfoBz.SaveOrUpdate(entity, entity.ID > 0); if (isSuccess) { ViewBag.Msg = "保存成功!"; } else { ViewBag.Msg = "保存失败!"; } var model = UserInfoBz.Get(o => o.UserName == entity.UserName); return(View("UserEidt", model)); }
public JsonResult SaveUpdatePwd(string oldPwd, string newPwd) { if (oldPwd != CurrentUser.Pwd) { return(Json(new { isSuccess = false, Msg = "旧密码错误!" })); } var user = UserInfoBz.Get(o => o.UserName == CurrentUser.UserName); user.Pwd = UserInfoBz.GetPwdAES(newPwd); bool isSuccess = UserInfoBz.Update(user); if (isSuccess) { SessionHelper.Del("CurUser"); UserInfoBz.ClearAccountCookie(); } return(Json(new { isSuccess = isSuccess, Msg = isSuccess ? "修改成功!" : "修改失败!" })); }