Exemplo n.º 1
0
        private void Search()
        {
            if (!String.IsNullOrWhiteSpace(SearchText))
            {
                // Create a query for blocked Ids (current user's blocked users and users who blocked current user)
                List <string> filteredIds =
                    _blockedUserService.GetUsersWhoBlockedUser(_context.CurrentUser).Select(u => u.Id)
                    .Union(_blockedUserService.GetBlockedUsersForUser(_context.CurrentUser).Select(u => u.BlockedUID)).ToList();

                // Add the curernt user's id to filtered Ids
                filteredIds.Add(_context.CurrentUser.Id);

                // Create the search
                UserSearch search = new UserSearch
                {
                    SearchText  = SearchText,
                    MaxResults  = 10,
                    FilteredIds = filteredIds
                };

                // Retrieve and set users
                Users = _userService.GetUsers(search).ToList();

                if (!Users.Any())
                {
                    SearchMessage = "No users could be found matching the search criteria.";
                }
            }
            else
            {
                // Search text is empty or whitespace so set empty list
                Users         = new List <User>();
                SearchMessage = "Search for users by entering a username or part of one and clicking the Search button.";
            }
        }
Exemplo n.º 2
0
 public void OnGet()
 {
     BlockedUsers = _blockedUserService.GetBlockedUsersForUser(_context.CurrentUser).ToList();
 }