Beispiel #1
0
        public async Task <IViewComponentResult> InvokeAsync()
        {
            var blockedIds   = blockService.BlockedByCurrent();
            var blockedUsers = blockedIds
                               .Select(uid => new UserNoPass(userInfoService.GetUserWithId(uid))).ToList();


            return(View("PersonalBlockedList", blockedUsers));
        }
Beispiel #2
0
        public List <Users> GetRandomUsers(Random random)
        {
            var results = new List <Users>();
            var users   = new List <Users>();

            if (CurrentUser.IsAuthenticated)
            {
                // nu iau oameni blocati sau prieteni sau pe mine

                var blockedUsers = blockService.BlockedByCurrent();
                var friends      = friendsService.FriendsOf().Where(f => f != null).Select(f => f.Id);
                users = unit.Users.Get()
                        .Where(u => u.Id != int.Parse(CurrentUser.Id) &&
                               !blockedUsers.Contains(u.Id) &&
                               !friends.Contains(u.Id))
                        .ToList();
            }
            else
            {
                users = unit.Users.Get().ToList();
            }


            var count   = random.Next(3, users.Count);
            var usedIds = new List <int>();

            for (int i = 0; i < count; ++i)
            {
                var randIndex = random.Next(1, users.Count);

                // verific sa nu trimit date despre acelasi user de 2 ori
                if (!usedIds.Contains(randIndex))
                {
                    var randUsr = users[randIndex];
                    usedIds.Add(randIndex);
                    results.Add(randUsr);
                }
                else
                {
                    i--;
                }
            }

            return(results);
        }