Пример #1
0
        public ActionResult UserEidt(int id = 0)
        {
            var model = UserInfoBz.Get(o => o.ID == id);

            ViewBag.selectList = GetSelectList();
            return(View(model));
        }
Пример #2
0
        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));
        }
Пример #3
0
        // GET: BackStage/User
        public ActionResult UserConfig(string msg = "")
        {
            var model = UserInfoBz.Get(o => o.ID == CurrentUser.ID);

            ViewBag.selectList = GetSelectList();
            ViewBag.Msg        = msg;
            return(View(model));
        }
Пример #4
0
        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 ? "修改成功!" : "修改失败!" }));
        }
Пример #5
0
        public ActionResult SaveUserConfig(UserInfo entity)
        {
            var userInfo = UserInfoBz.Get(o => o.ID == entity.ID);

            userInfo.UserName     = entity.UserName;
            userInfo.IsValid      = entity.IsValid;
            userInfo.IsSuperAdmin = entity.IsSuperAdmin;
            userInfo.HeadImgUrl   = entity.HeadImgUrl;
            userInfo.RoleID       = entity.RoleID;
            var isSuccess = UserInfoBz.Update(userInfo);

            if (isSuccess)
            {
                ViewBag.Msg = "保存成功!";
            }
            else
            {
                ViewBag.Msg = "保存失败!";
            }
            return(RedirectToAction("UserConfig", new { msg = ViewBag.Msg }));
        }