Exemplo n.º 1
0
        /// <summary>
        /// 角色批量添加人员
        /// </summary>
        /// <param name="roleId"></param>
        /// <param name="userIds"></param>
        /// <returns></returns>
        public bool AddUserForRole(int roleId, List <int> userIds)
        {
            bool            result          = true;
            UserRoleManager userRoleManager = new UserRoleManager();

            if (userIds != null && userIds.Count > 0)
            {
                List <WXQ.Enties.UserRole> lt = new List <Enties.UserRole>();
                DateTime dt = DateTime.Now;
                foreach (int m in userIds)
                {
                    if (!UserExitInRole(m, roleId))
                    {
                        WXQ.Enties.UserRole rm = new Enties.UserRole
                        {
                            UserId      = m,
                            RoleId      = roleId,
                            AddDateTime = dt,
                            AddUser     = this.OpUserId.ToString()
                        };
                        userRoleManager.Db.Insertable <WXQ.Enties.UserRole>(rm).AddQueue();
                    }
                }
                result = userRoleManager.Db.SaveQueues() > 0;
            }

            return(result);
        }
Exemplo n.º 2
0
        public bool AddUserForRole(int roleId, int userId)
        {
            UserRoleManager userRoleManager = new UserRoleManager();

            WXQ.Enties.UserRole rm = new Enties.UserRole
            {
                UserId      = userId,
                RoleId      = roleId,
                AddDateTime = DateTime.Now,
                AddUser     = this.OpUserId.ToString()
            };
            return(userRoleManager.Insert(rm));
        }