コード例 #1
0
ファイル: UserTasks.cs プロジェクト: scottccoates/CliqFlip
        public void StartConversation(string starter, string receiver, string messageText, string subject, string body)
        {
            //get the users involved in the conversation
            User sender = GetUser(starter),
                 recipient = GetUser(receiver);

            //check that both users exists
            //TODO: don't just return - throw ex when this kind of thing happens
            if (sender == null || recipient == null)
                return;

            //get the conversation that the recipient has with the sender, if any
            Conversation conversation = recipient.Conversations.SingleOrDefault(x => x.Users.Any(user => user.Username == starter));

            if (conversation == null)
            {
                //start a new conversation
                conversation = new Conversation(sender, recipient);
            }

            Message message = sender.WriteMessage(messageText);
            conversation.AddMessage(message);
            _conversationRepository.SaveOrUpdate(conversation); //TODO:remove this - it will be taken care of automatically
            _emailService.SendMail(recipient.Email, subject, body);
        }
コード例 #2
0
ファイル: User.cs プロジェクト: scottccoates/CliqFlip
 protected internal virtual void Subscribe(Conversation conversation)
 {
     _conversations.Add(conversation);
 }
コード例 #3
0
ファイル: UserTasks.cs プロジェクト: scottccoates/CliqFlip
        public Message ReplyToConversation(Conversation conversation, User sender, User receiver, string messageText, string subject, string body)
        {
            Message retVal = null;

            if (sender != null)
            {
                //TODO - don't just check or null - throw ex or don't check at all
                if (conversation != null)
                {
                    retVal = sender.WriteMessage(messageText);

                    conversation.AddMessage(retVal);

                    _emailService.SendMail(receiver.Email, subject, body);
                }
            }
            return retVal;
        }