Exemple #1
0
        public ICollection <Model.ChatRoom> GetChatRoomsForUser(Guid userId)
        {
            var chatRoomUsers = _chatRoomUserRepository.Where(x => x.UserId == userId);

            if (!chatRoomUsers.Any())
            {
                return(new List <Model.ChatRoom>());
            }

            var chatRoomUserIds = chatRoomUsers.Select(x => x.ChatRoomId).Distinct().ToList();

            var rooms = _chatRoomRepository.Where(x => chatRoomUserIds.Contains(x.Id)).ToList();

            return(rooms);
        }
 public ICollection <ChatRoomUser> GetChatRoomUsers(Guid roomId)
 {
     return(_chatRoomUserRepository.Where(x => x.ChatRoomId == roomId).ToList());
 }