Beispiel #1
0
        public void AddFriend(string friendId)
        {
            this.Init();

            var friend = this._chatRepository.GetUserByUserId(ConnectedUsers, friendId);

            // store message to database
            IFriendRepository friendRepository = new FriendRepository(this._dbContext);
            friendRepository.AddFriend(this._curUserChat.UserId, friendId);

            // friend online
            if (friend != null)
            {
                Clients.Client(friend.ConnectionId).notifyAddFriend(this._curUserChat.Displayname);
            }
        }
        public IEnumerable <string> GetListStatusIdNewest(string userId, string preStatusId)
        {
            IFriendRepository friendRepository = new FriendRepository(this._db);
            var friendListUserId = friendRepository.GetFriendListId(userId);

            List <string> listUserIdBoardcast = new List <string>();

            if (friendListUserId != null && friendListUserId.Count() > 0)
            {
                listUserIdBoardcast.AddRange(friendListUserId);
            }
            listUserIdBoardcast.Add(userId);

            List <string> listStatusIdNewest = new List <string>();

            foreach (var id in listUserIdBoardcast)
            {
                var listStatusId = this.GetListStatusId(id, preStatusId);
                listStatusIdNewest.AddRange(listStatusId);
            }

            return(listStatusIdNewest.OrderByDescending(p => p)
                   .Take(5));
        }