示例#1
0
        public IActionResult Edit(int ID)
        {
            ViewBag.ID = ID;
            YS_Account_User model = _ys_Account_UserService.FindByClause(f => f.Account_Uid == ID && f.Status == 0);

            return(View("Add"));
        }
示例#2
0
        public IActionResult SaveInfo(YS_Account_User vmodel)
        {
            int    code = 0;
            string msg  = string.Empty;

            if (vmodel != null)
            {
                if (string.IsNullOrEmpty(vmodel.Account_Name))
                {
                    return(Json(new { code = 0, msg = "用户名不能为空" }));
                }
                if (string.IsNullOrEmpty(vmodel.Account_Pwd))
                {
                    return(Json(new { code = 0, msg = "密码不能为空" }));
                }
                var info = _ys_Account_UserService.FindByClause(f => f.Account_Name == vmodel.Account_Name && f.Status == 0);
                if (vmodel.Account_Uid > 0)
                {
                    if (info == null)
                    {
                        info = _ys_Account_UserService.FindByClause(f => f.Account_Uid == vmodel.Account_Uid && f.Status == 0);
                    }
                    if (info.Account_Uid != vmodel.Account_Uid)
                    {
                        return(Json(new { code = 0, msg = "该账号名称已存在,请重新输入一个名称" }));
                    }
                    if (!string.IsNullOrEmpty(info.Mobile) && info.Account_Name != vmodel.Account_Name)
                    {
                        return(Json(new { code = 0, msg = "该账号已被绑定,无法修改账户名称" }));
                    }
                    if (!info.Account_Pwd.Equals(vmodel.Account_Pwd))
                    {
                        info.Account_Pwd = Tools.MD5Encryption(vmodel.Account_Pwd);
                        info.Pwd_Display = vmodel.Account_Pwd;
                    }
                    info.Account_Name = vmodel.Account_Name;
                    var result = _ys_Account_UserService.Update(info);
                    if (result)
                    {
                        code = 200;
                        msg  = "更新成功";
                    }
                }
                else
                {
                    var adminUid = this.User.Claims.Where(n => n.Type == "ID").FirstOrDefault().Value;
                    if (info != null)
                    {
                        return(Json(new { code = 0, msg = "该账号已存在,请更换其它名称" }));
                    }
                    vmodel.Pwd_Display = vmodel.Account_Pwd;
                    vmodel.Account_Pwd = Tools.MD5Encryption(vmodel.Account_Pwd);
                    vmodel.CreateTime  = DateTime.Now;
                    vmodel.CreateId    = adminUid;
                    vmodel.IsUseed     = 0;
                    vmodel.Status      = 0;
                    var result = _ys_Account_UserService.Insert(vmodel);
                    if (result > 0)
                    {
                        code = 200;
                        msg  = "保存成功";
                    }
                }
            }
            else
            {
                return(Json(new { code = code, msg = "缺少参数" }));
            }
            return(Json(new { code = code, msg = msg }));
        }