public ConversationMessageDto(cf.Entities.Message m)
 {
     ID       = m.ID.ToString("N");
     Content  = m.Content;
     SenderID = m.SenderID.ToString("N");
     Utc      = m.Utc.ToEpochTimeString();
 }
 public void UserDeleteMessage(Conversation conversation, Message msg)
 {
     throw new NotImplementedException("UserDeleteMessage");
 }
        /// <summary>
        /// Log when someone responds to a partner call by private message
        /// </summary>
        /// <param name="pc"></param>
        /// <param name="message"></param>
        public void LogPartnerCallMessageReply(PartnerCall pc, Message message)
        {
            if (pc.UserID == message.SenderID) { throw new ArgumentException("Cannot reply to your own partner call!!"); }

            var pcr = new PartnerCallReply() { ID = Guid.NewGuid(), Message = message.Content, PartnerCallID = pc.ID,
                 TypeID = (byte)PartnerCallReplyType.Message, Utc = DateTime.UtcNow, UserID = message.SenderID };

            AddPartnerCallSubscriptionWorkItemReply(pc, pcr);
        }
        /// <summary>
        /// Send a message!
        /// </summary>
        /// <param name="toID"></param>
        /// <param name="content"></param>
        /// <returns></returns>
        public Message SendMessage(Guid toID, string content)
        {
            var excerpt = content;
            if (content.Length > 80) { excerpt = content.Substring(0, 80); }

            var conversation = GetConversationByPartyIDs(CfIdentity.UserID, toID);
            if (conversation == null) { conversation = CreateConversation(toID, excerpt); }
            else
            {
                conversation.LastActivityUtc = DateTime.UtcNow;
                conversation.LastSenderID = CfIdentity.UserID;
                conversation.LastExcerpt = excerpt;
                convoRepo.Update(conversation);
            }

            var msg = new Message() { ID = Guid.NewGuid(), Content = content, SenderID = CfIdentity.UserID };
            msg.Utc = DateTime.UtcNow;
            msg.ConversationID = conversation.ID;

            msg.MessagePartyStatus.Add(new MessagePartyStatus() { ID = Guid.NewGuid(), PartyID = toID, Status = (byte)MessageStatus.Unread });
            msg.MessagePartyStatus.Add(new MessagePartyStatus() { ID = Guid.NewGuid(), PartyID = CfIdentity.UserID, Status = (byte)MessageStatus.Read });

            new MessageRepository().Create(msg);

            //-- Send off Alerts!!
            new AlertsService().EnqueMessageWorkItem(toID, CfIdentity.UserID, msg.Content);

            return msg;
        }