Esempio n. 1
0
 /// <summary>
 /// TODO: This method should not be exposed as public method -> find another way to connect friends by accepting invitations
 /// </summary>
 /// <param name="user"></param>
 public void AddFriend(UserInfo user)
 {
     if (!Friends.Any(f => f.UserId == user.UserId))
     {
         _friends.Add(user);
     }
 }
Esempio n. 2
0
 private IEnumerable <User> GetHaveNotFollowedUsers()
 {
     foreach (var user in Followers)
     {
         if (!Friends.Any(e => e.Id == user.Id))
         {
             yield return(user);
         }
     }
 }
        public async Task GetFriends()
        {
            IEnumerable <Friend> friends = await friendsService.Get();

            // очищаем список
            //Friends.Clear();
            while (Friends.Any())
            {
                Friends.RemoveAt(Friends.Count - 1);
            }

            // добавляем загруженные данные
            foreach (Friend f in friends)
            {
                Friends.Add(f);
            }
        }
Esempio n. 4
0
        private async Task SearchPerson(string query)
        {
            await semaphoreSlim.WaitAsync();

            _lastQuery = query;

            if (query.Length > 2)
            {
                EmeptyViewText = "No match found";
            }
            else
            {
                EmeptyViewText = "Minimum 3 Characters...";
            }

            try
            {
                if (!string.IsNullOrEmpty(query) && query.Length > 2)
                {
                    var SearchPersonResponse = await _dbHelper.SearchPerson(new SearchPersonRequest
                    {
                        Query = query
                    });

                    var queryFriends = SearchPersonResponse.Results.Select(o => (Friend)o);
                    UpdateFriendsResults(queryFriends);
                    if (!Friends.Any())
                    {
                        Friends.Clear();
                    }
                }
                else
                {
                    Friends.Clear();
                }

                OnPropertyChanged(nameof(EmeptyViewText));
            }
            finally
            {
                semaphoreSlim.Release();
            }
        }
        public async void NavigatedTo(FriendsPageNavArgs args)
        {
            if (args.Equals(_lastArgs))
            {
                return;
            }
            if (_friendsCache.ContainsKey(args.TargetUser.Name.ToLower()))
            {
                Friends = new ObservableCollection <MalFriend>(_friendsCache[args.TargetUser.Name.ToLower()]);
            }
            else
            {
                Loading = true;
                Friends = new ObservableCollection <MalFriend>();

                var result = (await new FriendsQuery(args.TargetUser.Name).GetFriends()) ?? new List <MalFriend>();
                _friendsCache[args.TargetUser.Name.ToLower()] = result;

                Friends = new ObservableCollection <MalFriend>(result);
                Loading = false;
            }

            if (args.TargetUser.Name.Equals(Credentials.UserName, StringComparison.CurrentCultureIgnoreCase))
            {
                ShowPending = true;
                if (_requests == null)
                {
                    RefreshPendingCommand.Execute(null);
                }
            }
            else
            {
                ShowPending = false;
            }

            FriendsEmptyNoticeVisibility = !Friends.Any();

            _lastArgs = args;
        }
Esempio n. 6
0
        public async Task GetFriends()
        {
            if (initialized == true)
            {
                return;
            }
            IsBusy = true;
            IEnumerable <Friend> friends = await friendsService.Get();

            // очищаем список
            Friends.Clear();
            while (Friends.Any())
            {
                Friends.RemoveAt(Friends.Count - 1);
            }

            // добавляем загруженные данные
            foreach (Friend f in friends)
            {
                Friends.Add(f);
            }
            IsBusy      = false;
            initialized = true;
        }
Esempio n. 7
0
            public bool AddFriend(string friendName, Serial friendSerial)
            {
                if (Friends.Any(f => f.Serial == friendSerial) == false)
                {
                    Friend newFriend = new Friend
                    {
                        Name   = friendName,
                        Serial = friendSerial
                    };

                    Friends.Add(newFriend);

                    if (_friendGroups.SelectedItem == this)
                    {
                        RedrawList(this);
                    }

                    World.Player?.SendMessage(MsgLevel.Friend, $"Added '{friendName}' to '{GroupName}'");

                    return(true);
                }

                return(false);
            }
Esempio n. 8
0
 public bool Lonely() => As.Expression(() => !Friends.Any());
Esempio n. 9
0
 public bool IsFriend(string email)
 {
     return(Friends.Any(friend => friend.ToLower().Equals(email.ToLower())));
 }