private static bool IsConversationValid(ConversationRequest conversationRequest, ParticipationRepository participationRepository)
        {
            if (conversationRequest.UserIds.Count != conversationRequest.UserIds.Distinct().Count())
            {
                Log.Warn("Cannot make a conversation between two users of same id.");
                return(false);
            }

            return(!participationRepository.DoesConversationWithUsersExist(conversationRequest.UserIds));
        }
        public void DoesConversationWithUsersExistTest()
        {
            var participationRepository = new ParticipationRepository();
            var participation           = new Participation(1, 1, 1);

            participationRepository.AddEntity(participation);

            Assert.True(participationRepository.DoesConversationWithUsersExist(new List <int> {
                participation.UserId
            }));
        }
Exemplo n.º 3
0
        private void NewConversation(List <int> userIds)
        {
            IsMultiUserConversation = false;

            if (!participationRepository.DoesConversationWithUsersExist(userIds))
            {
                clientService.CreateConversation(userIds);
            }
            else
            {
                int conversationId = participationRepository.GetConversationIdByUserIds(userIds);
                ConversationWindowManager.CreateConversationWindow(ServiceRegistry, conversationRepository.FindEntityById(conversationId));
            }
        }