Exemple #1
0
        public void RemoveFromFriends(User friend)
        {
            if (Id == friend.Id)
            {
                throw new Exception("You can not remove yourself");
            }

            UserFriends.Where(f => f.User.Id == friend.Id || f.Friend.Id == friend.Id)
            .ToList()
            .ForEach(userFriend =>
            {
                UserFriends.Remove(userFriend);
            });
        }
Exemple #2
0
        void InitializeCommands()
        {
            CreateGroupCommand = new RelayCommand(param =>
            {
                Window currentWindow         = (Window)param;
                List <ChatUserDTO> chatUsers = new List <ChatUserDTO>();
                foreach (UserModel userModel in UserFriends.Where(um => um.IsSelected))
                {
                    chatUsers.Add(new ChatUserDTO()
                    {
                        IsAdmin = false
                        ,
                        IsCreator = false
                        ,
                        UserId = userModel.User.UserId
                    }


                                  );
                }
                chatUsers.Add(new ChatUserDTO()
                {
                    IsAdmin   = true,
                    IsCreator = true,
                    UserId    = NetworkManager.CurrentUser.UserId
                });


                NetworkManager.Client.CreateChat(new ChatDTO()
                {
                    Name = GroupName, Description = GroupDescription
                }, chatUsers);
                currentWindow.DialogResult = true;
                currentWindow.Close();
            });
            CancleCommand = new RelayCommand(param =>
            {
                Window currentWindow       = (Window)param;
                currentWindow.DialogResult = false;
                currentWindow.Close();
            });
        }
 // Check to see if the user is friends with the friendId.
 public bool IsFriend(string userId, string friendId)
 {
     return(UserFriends.Where(m => m.UserId == userId && m.FriendId == friendId).FirstOrDefault() != null);
 }