Beispiel #1
0
        /// <summary>
        /// 更新一个人员的所属角色
        /// </summary>
        /// <param name="userID"></param>
        public void UpdateByUserID(Guid userID)
        {
            Organize  borg       = new Organize();
            UsersRole busersRole = new UsersRole();
            var       roles      = new Role().GetAll();

            busersRole.DeleteByUserID(userID);
            foreach (var role in roles)
            {
                if (role.UseMember.IsNullOrEmpty())
                {
                    continue;
                }
                var users = borg.GetAllUsers(role.UseMember);
                if (users.Exists(p => p.ID == userID))
                {
                    busersRole.Add(new MyCreek.Data.Model.UsersRole()
                    {
                        IsDefault = true,
                        MemberID  = userID,
                        RoleID    = role.ID
                    });
                }
            }
            ClearCache();
        }
Beispiel #2
0
        /// <summary>
        /// 从数据库获取所有意见列表
        /// </summary>
        /// <returns></returns>
        private List <Tuple <Guid, string, int, int, List <Guid> > > getAllListByDb()
        {
            var      comments  = GetAll();
            Organize borganize = new Organize();
            List <Tuple <Guid, string, int, int, List <Guid> > > list = new List <Tuple <Guid, string, int, int, List <Guid> > >();

            foreach (var comment in comments)
            {
                List <Guid> userList = new List <Guid>();
                if (!comment.MemberID.IsNullOrEmpty())
                {
                    var users = borganize.GetAllUsers(comment.MemberID);
                    foreach (var user in users)
                    {
                        userList.Add(user.ID);
                    }
                }

                Tuple <Guid, string, int, int, List <Guid> > tuple = new Tuple <Guid, string, int, int, List <Guid> >(
                    comment.ID,
                    comment.Comment,
                    comment.Type,
                    comment.Sort,
                    userList
                    );
                list.Add(tuple);
            }
            return(list);
        }