Beispiel #1
0
        public ActionResult RemoveRoleUser(long group, IEnumerable <long> datas)
        {
            ModifyUserBindRoleCmdDto bindInfo = new ModifyUserBindRoleCmdDto()
            {
                UnBinds = datas.Select(c => new Tuple <UserCmdDto, RoleCmdDto>(new UserCmdDto()
                {
                    SysNo = c
                }, new RoleCmdDto()
                {
                    SysNo = group
                }))
            };

            return(Json(userService.ModifyUserBindRole(bindInfo)));
        }
Beispiel #2
0
        public ActionResult AddUserRole(long userId, IEnumerable <long> roleIds)
        {
            ModifyUserBindRoleCmdDto bindInfo = new ModifyUserBindRoleCmdDto()
            {
                Binds = roleIds.Select(c => new Tuple <UserCmdDto, RoleCmdDto>(new UserCmdDto()
                {
                    SysNo = userId
                }, new RoleCmdDto()
                {
                    SysNo = c
                }))
            };

            return(Json(userService.ModifyUserBindRole(bindInfo)));
        }
        /// <summary>
        /// 修改用户绑定角色
        /// </summary>
        /// <param name="bindInfo">绑定信息</param>
        public Result ModifyUserBindRole(ModifyUserBindRoleCmdDto bindInfo)
        {
            if (bindInfo == null || (bindInfo.Binds.IsNullOrEmpty() && bindInfo.UnBinds.IsNullOrEmpty()))
            {
                return(Result.FailedResult("没有指定任何要修改的绑定信息"));
            }
            using (var businessWork = WorkFactory.Create())
            {
                //解绑
                if (!bindInfo.UnBinds.IsNullOrEmpty())
                {
                    userRoleService.UnBindUserAndRole(bindInfo.UnBinds.Select(c => new Tuple <User, Role>(User.CreateUser(c.Item1?.SysNo ?? 0), Role.CreateRole(c.Item2?.SysNo ?? 0))).ToArray());
                }
                //绑定
                if (!bindInfo.Binds.IsNullOrEmpty())
                {
                    userRoleService.BindUserAndRole(bindInfo.Binds.Select(c => new Tuple <User, Role>(User.CreateUser(c.Item1?.SysNo ?? 0), Role.CreateRole(c.Item2?.SysNo ?? 0))).ToArray());
                }

                var commitResult = businessWork.Commit();
                return(commitResult.ExecutedSuccess ? Result.SuccessResult("修改成功") : Result.FailedResult("修改失败"));
            }
        }
Beispiel #4
0
 /// <summary>
 /// 修改用户绑定角色
 /// </summary>
 /// <param name="bindInfo">绑定信息</param>
 public Result ModifyUserBindRole(ModifyUserBindRoleCmdDto bindInfo)
 {
     return(userBusiness.ModifyUserBindRole(bindInfo));
 }