示例#1
0
        public List<SubUserBanWrapped> Wrap(List<SubUserBan> items)
        {
            var users =
                _membershipService.GetUsersByIds(
                    items.Select(x => x.UserId).Union(items.Select(x => x.BannedBy)).Distinct().ToList())
                    .ToDictionary(x => x.Id, x => x);

            return items.Select(x =>
                {
                    var wrapped = new SubUserBanWrapped(x)
                    {
                        User = users.ContainsKey(x.UserId) ? users[x.UserId] : null,
                        BannedBy = users.ContainsKey(x.BannedBy) ? users[x.BannedBy] : null
                    };
                    return wrapped;
                })
                .ToList();
        }
示例#2
0
        public List <SubUserBanWrapped> Wrap(List <SubUserBan> items)
        {
            var users = _membershipDao.GetUsersByIds(
                items.Select(x => x.UserId).Union(items.Select(x => x.BannedBy)).Distinct().ToList())
                        .ToDictionary(x => x.Id, x => x);

            return(items.Select(x =>
            {
                var wrapped = new SubUserBanWrapped(x)
                {
                    User = users.ContainsKey(x.UserId) ? users[x.UserId] : null,
                    BannedBy = users.ContainsKey(x.BannedBy) ? users[x.BannedBy] : null
                };

                return wrapped;
            })
                   .ToList());
        }