Esempio n. 1
0
        public ActionResult Edit([FromForm] SystemUserEdit model)
        {
            if (model.Id == 1)
            {
                return(Json(ResponseHelper.Error("该用户不可被编辑")));
            }
            if (!string.IsNullOrEmpty(model.Pwd))
            {
                if (model.Pwd.Length < 6 || model.Pwd.Length > 16)
                {
                    return(Json(ResponseHelper.Error("密码长度不能少于6位大于16位!")));
                }
            }
            var UserModel = SystemUserHelper.GetModel(model.Id);

            //查询是否存重名
            if (SystemUserHelper.Exists(p => p.Id != model.Id && (p.Phone.Equals(model.Phone) || p.Email.Equals(model.Email))))
            {
                return(Json(new { status = 0, msg = "已存在相同的手机号或者邮箱,请修改!" }));
            }
            UserModel.Email = model.Email;

            UserModel.Status   = model.IsUse;
            UserModel.NickName = model.Name;
            UserModel.Phone    = model.Phone;
            if (!string.IsNullOrEmpty(model.Pwd))
            {
                UserModel.Password = AESUtil.Md5(model.Pwd);
            }
            SystemUserHelper.Update(UserModel);
            return(Json(ResponseHelper.Success("ok")));
        }
Esempio n. 2
0
        public ActionResult ChangeStatus()
        {
            var status = Convert.ToInt16(Request.Form["status"]);
            var code   = int.Parse(Request.Form["id"]);

            SystemUserHelper.Update(new SystemUser {
                Id = code, Status = status
            }, SystemUserHelper.Columns.Status);
            return(new JsonResult(ResponseHelper.Success("ok")));
        }