Esempio n. 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);
        }