private bool AddUserToGroup(ISession session, int userId, int groupId)
        {
            UserToGroup utg = new UserToGroup();

            utg.CreateTime = DateTime.Now;
            utg.GroupId    = groupId;
            utg.OperateBy  = SecuritySession.CurrentUser.UserId;
            utg.UserId     = userId;

            return(utg.Create(session));
        }
Beispiel #2
0
        /// <summary>
        /// 从当前Group中删除User
        /// </summary>
        /// <param name="users"></param>
        /// <returns></returns>
        public bool RemoveUserFromGroup(IList <UserBase> users, ISession session)
        {
            bool flag = false;

            foreach (UserBase user in users)
            {
                flag = UserToGroup.Delete(session, this.GroupId, user.UserId) == 1;
                if (!flag)
                {
                    throw new ApplicationException(string.Format("删除用户{0}失败", user.UserName));
                }
            }

            return(flag);
        }
Beispiel #3
0
        /// <summary>
        /// 新增用户到用户组
        /// </summary>
        /// <param name="user"></param>
        /// <param name="session"></param>
        /// <returns></returns>
        public bool AddUser(UserBase user, ISession session)
        {
            if (!this.UserIsInGroup(user, session))
            {
                UserToGroup utg = new UserToGroup();
                utg.CreateTime = DateTime.Now;
                utg.GroupId    = this.GroupId;
                utg.OperateBy  = SecuritySession.CurrentUser.UserId;
                utg.UserId     = user.UserId;

                return(utg.Create(session));
            }
            else
            {
                return(false);
            }
        }
Beispiel #4
0
        /// <summary>
        /// 新增用户到用户组
        /// </summary>
        /// <param name="user"></param>
        /// <param name="session"></param>
        /// <returns></returns>
        public bool AddUser(UserBase user, ISession session)
        {
            if (!this.UserIsInGroup(user, session))
            {
                UserToGroup utg = new UserToGroup();
                utg.CreateTime = DateTime.Now;
                utg.GroupId = this.GroupId;
                utg.OperateBy = SecuritySession.CurrentUser.UserId;
                utg.UserId = user.UserId;

                return utg.Create(session);
            }
            else
            {
                return false;
            }
        }
        private bool AddUserToGroup(ISession session, int userId, int groupId)
        {
            UserToGroup utg = new UserToGroup();
            utg.CreateTime = DateTime.Now;
            utg.GroupId = groupId;
            utg.OperateBy = SecuritySession.CurrentUser.UserId;
            utg.UserId = userId;

            return utg.Create(session);
        }
 private bool RemoveUserFromGroup(ISession session, int groupId, int userId)
 {
     return(UserToGroup.Delete(session, groupId, userId) > 0);
 }