private void SendConversationNotificationToParticipants(Conversation conversation, int newParticipantUserId, IEnumerable <Participation> otherParticipants) { if (conversation != null) { ClientManager.SendMessageToClient(new EntityNotification <Conversation>(conversation, NotificationType.Create), newParticipantUserId); IEnumerable <int> currentConversationParticipantUserIds = otherParticipants.Select(participant => participant.UserId); ClientManager.SendMessageToClients(new EntityNotification <Conversation>(conversation, NotificationType.Update), currentConversationParticipantUserIds); } }
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); }