Inheritance: System.Data.Objects.DataClasses.EntityObject
 /// <summary>
 /// Deprecated Method for adding a new object to the Messages EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToMessages(Message message)
 {
     base.AddObject("Messages", message);
 }
        private List<Message> GetMessages(XmlNodeList messages)
        {
            var result = new List<Message>();

            if (messages.Count <= 0)
            {
                return result;
            }

            foreach (XmlNode message in messages)
            {
                // todo get author id

                var author = message.SelectSingleNode("Author").InnerText;
                var content = message.SelectSingleNode("Content").InnerText;
                var sentOn = message.SelectSingleNode("SentOn").InnerText;
                var seenOn = message.SelectSingleNode("SeenOn") == null ? null : message.SelectSingleNode("SeenOn").InnerText;

                var msg = new Message();
                msg.Content = content;
                msg.SendTime = DateTime.Parse(sentOn);
                msg.AuthorId = this.data.Users.First(x => x.UserName == author).Id;

                if (!string.IsNullOrWhiteSpace(seenOn))
                {
                    msg.SeeingDate = DateTime.Parse(seenOn);
                }

                result.Add(msg);
            }

            return result;
        }
 /// <summary>
 /// Create a new Message object.
 /// </summary>
 /// <param name="messageID">Initial value of the MessageID property.</param>
 /// <param name="senderAccountID">Initial value of the SenderAccountID property.</param>
 /// <param name="recepientAccountID">Initial value of the RecepientAccountID property.</param>
 /// <param name="datetime">Initial value of the Datetime property.</param>
 /// <param name="messageText">Initial value of the MessageText property.</param>
 public static Message CreateMessage(global::System.Int32 messageID, global::System.Int32 senderAccountID, global::System.Int32 recepientAccountID, global::System.DateTime datetime, global::System.String messageText)
 {
     Message message = new Message();
     message.MessageID = messageID;
     message.SenderAccountID = senderAccountID;
     message.RecepientAccountID = recepientAccountID;
     message.Datetime = datetime;
     message.MessageText = messageText;
     return message;
 }
        public void SendMessage(DialogModel newMessage)
        {
            Message msg = new Message();
            msg.SenderAccountID = newMessage.SenderID;
            msg.RecepientAccountID = newMessage.RecepientID;
            msg.Datetime = DateTime.Now;
            msg.Subject = newMessage.Subject;
            msg.MessageText = newMessage.MessageText;

            _db.Messages.AddObject(msg);
            _db.SaveChanges();
        }