示例#1
0
        public ActionResult PostUserRole()
        {
            string roleids = DoRequest.GetFormString("roleids");
            int    userid  = DoRequest.GetFormInt("userid");

            List <UserRoleList> oldlist = new List <UserRoleList>();
            var reslist = GetUserRole.Do(userid);

            if (reslist != null && reslist.Body != null && reslist.Body.user_role_list != null)
            {
                oldlist = reslist.Body.user_role_list;
            }

            string[]   newidss = roleids.Split(',');
            List <int> newids  = new List <int>();

            foreach (string em in newidss)
            {
                newids.Add(Utils.StrToInt(em, 0));
            }

            string delids = "";
            int    _count = 0;

            foreach (UserRoleList em in oldlist)
            {
                if (!newids.Contains(em.role_id))
                {
                    if (_count == 0)
                    {
                        delids = em.role_id.ToString();
                    }
                    else
                    {
                        delids = delids + "," + em.role_id.ToString();
                    }
                }
            }
            if (delids.Equals(""))
            {
                delids = "0";
            }
            int returnValue = -1;
            var res         = OpUserRole.Do(userid, roleids, delids);

            if (res != null && res.Header != null && res.Header.Result != null && res.Header.Result.Code != null)
            {
                returnValue = Utils.StrToInt(res.Header.Result.Code, -1);
            }
            if (returnValue == 0)
            {
                return(Json(new { error = false, message = "操作成功!" }));
            }

            return(Json(new { error = true, message = "操作失败!" }));
        }
示例#2
0
        public ActionResult GetRoleList()
        {
            int                 userid   = DoRequest.GetFormInt("id");
            List <RoleInfo>     item1    = new List <RoleInfo>();
            List <UserRoleList> item2    = new List <UserRoleList>();
            var                 resrole  = QueryRoleList.Do();
            var                 resrole2 = GetUserRole.Do(userid);

            if (resrole != null && resrole.Body != null && resrole.Body.role_list != null && resrole2 != null && resrole2.Body != null && resrole2.Body.user_role_list != null)
            {
                item1 = resrole.Body.role_list;
                item2 = resrole2.Body.user_role_list;
                return(Json(new { error = false, role = item1, role2 = item2, message = "操作成功!" }));
            }

            return(Json(new { error = true, message = "操作失败" }));
        }