Example #1
0
        public ActionResult Edit(int id)
        {
            var model     = userBLL.Get(id);
            var userRoles = userRoleBLL.GetList(string.Format("UserCode='{0}'", model.UserCode)).Select(p => p.RoleCode);

            ViewBag.Roles         = GetRolesSelect(userRoles.ToList());
            ViewBag.UserRoleCodes = string.Join(",", userRoles);
            return(View(model));
        }
        public DataRes <bool> EditPassword(EditPasswordReq model)
        {
            DataRes <bool> res = new DataRes <bool>()
            {
                code = ResCode.Success, data = true
            };
            var user = User.GetNBCZUser();

            if (user == null)
            {
                res.code = ResCode.NoValidate;
                res.data = false;
                res.msg  = "用户未登陆";

                return(res);
            }
            var oldModel = bll.Get(user.Id);

            if (oldModel.UserPwd != model.OldPassword)
            {
                res.code = ResCode.NoValidate;
                res.data = false;
                res.msg  = "原密码不正确";

                return(res);
            }

            bll.EditPassword(user.Id, model.Password, user.UserCode + "-" + user.UserName);
            if (user == null)
            {
                res.code = ResCode.Error;
                res.data = false;
                res.msg  = "保存失败";
                return(res);
            }


            return(res);
        }