private void OnParticipationUpdated(object sender, EntityChangedEventArgs <Participation> e) { IEnumerable <string> listOfUsersTyping = from participant in participationRepository.GetParticipationsByConversationId(groupChat.Conversation.Id) where participant.UserTyping.IsUserTyping select userRepository.FindEntityById(participant.UserId).Username; string usersTyping = ChatWindowStringBuilder.CreateUsersTypingMessage(listOfUsersTyping.ToList()); GroupChat.UsersTyping = usersTyping; }
public ChatWindowViewModel(Conversation conversation, IServiceRegistry serviceRegistry) : base(serviceRegistry) { if (!IsInDesignMode) { userRepository = ServiceRegistry.GetService <RepositoryManager>().GetRepository <User>(); participationRepository = (ParticipationRepository)ServiceRegistry.GetService <RepositoryManager>().GetRepository <Participation>(); clientService = ServiceRegistry.GetService <IClientService>(); Participation participation = participationRepository.GetParticipationByUserIdandConversationId(clientService.ClientUserId, conversation.Id); groupChat = new GroupChatModel(participation); contributionMessageFormatter = new ContributionMessageFormatter(clientService.ClientUserId, userRepository); userRepository.EntityAdded += OnUserChanged; userRepository.EntityUpdated += OnUserChanged; ServiceRegistry.GetService <RepositoryManager>().GetRepository <Conversation>().EntityUpdated += OnConversationUpdated; participationRepository.EntityUpdated += OnParticipationUpdated; AddUserCommand = new AddUserToConversationCommand(this); groupChat.Conversation = conversation; groupChat.Users = GetUsers(); UpdateConnectedUsersList(); groupChat.WindowTitle = userRepository.FindEntityById(clientService.ClientUserId).Username; groupChat.Title = GetChatTitle(); } }
private Run FormatUser(IContribution contribution) { return(new Run(userRepository.FindEntityById(contribution.ContributorUserId).Username) { FontWeight = FontWeights.Bold }); }
public void UserGetsSetToDisconnectedInUserRepository() { HandleMessage(clientDisconnection); IReadOnlyEntityRepository <User> userRepository = ServiceRegistry.GetService <RepositoryManager>().GetRepository <User>(); User defaultUser = userRepository.FindEntityById(DefaultUser.Id); Assert.IsTrue(defaultUser.ConnectionStatus.UserConnectionStatus.Equals(ConnectionStatus.Status.Disconnected)); }
private string GetConversationParticipants() { var usernames = new List <string>(); var titleBuilder = new StringBuilder(); foreach (Participation participant in participationRepository.GetParticipationsByConversationId(conversation.Id)) { usernames.Add(userRepository.FindEntityById(participant.UserId).Username); } titleBuilder.Append(ChatWindowStringBuilder.CreateUserListTitle(usernames)); return(titleBuilder.ToString()); }
public MainWindowViewModel(IServiceRegistry serviceRegistry) : base(serviceRegistry) { if (!IsInDesignMode) { userRepository = ServiceRegistry.GetService <RepositoryManager>().GetRepository <User>(); userId = ServiceRegistry.GetService <IClientService>().ClientUserId; User user = userRepository.FindEntityById(userId); if (user.Avatar.UserAvatar != null) { UserAvatar = user.Avatar.UserAvatar; } userRepository.EntityUpdated += OnUserUpdated; } }
private void OnParticipationAdded(object sender, EntityChangedEventArgs <Participation> e) { Participation participation = e.Entity; List <Participation> conversationParticipants = participationRepository.GetParticipationsByConversationId(participation.ConversationId); var participationNotification = new EntityNotification <Participation>(participation, NotificationType.Create); IEnumerable <int> conversationParticipantUserIds = conversationParticipants.Select(conversationParticipation => conversationParticipation.UserId); ClientManager.SendMessageToClients(participationNotification, conversationParticipantUserIds); List <Participation> otherParticipants = conversationParticipants.Where(conversationParticipant => !conversationParticipant.Equals(participation)).ToList(); otherParticipants.ForEach( otherParticipant => ClientManager.SendMessageToClient(new EntityNotification <Participation>(otherParticipant, NotificationType.Create), participation.UserId)); Conversation conversation = conversationRepository.FindEntityById(participation.ConversationId); SendConversationNotificationToParticipants(conversation, participation.UserId, otherParticipants); }
public void GetConversationWindow(int conversationId) { ConversationWindowManager.CreateConversationWindow(ServiceRegistry, conversationRepository.FindEntityById(conversationId)); }
private void OnContributionAdded(IContribution contribution) { Conversation conversation = conversationRepository.FindEntityById(contribution.ConversationId); ConversationWindowManager.CreateConversationWindow(ServiceRegistry, conversation); }
private void OnContributionAdded(IContribution contribution) { var contributionNotification = new EntityNotification <IContribution>(contribution, NotificationType.Create); List <Participation> participationsByConversationId = participationRepository.GetParticipationsByConversationId(contribution.ConversationId); IEnumerable <User> participantUsers = participationsByConversationId.Select(participant => userRepository.FindEntityById(participant.UserId)); IEnumerable <int> connectedUserIds = participantUsers.Where(user => user.ConnectionStatus.UserConnectionStatus == ConnectionStatus.Status.Connected).Select(user => user.Id); ClientManager.SendMessageToClients(contributionNotification, connectedUserIds); }