public override Message CreateMessage(Topic topic, string idParentMessage, string owner, string title, string body, Attachment.FileInfo attachment) { //Check attachment if (attachment != null) { Attachment.FileHelper.CheckFile(attachment, topic.Category.AttachExtensions, topic.Category.AttachMaxSize); } using (TransactionScope transaction = new TransactionScope(mConfiguration)) { TopicDataStore topicStore = new TopicDataStore(transaction); topicStore.Attach(topic); MessageDataStore messageStore = new MessageDataStore(transaction); Message parentMessage = messageStore.FindByKey(idParentMessage); if (parentMessage == null) { throw new MessageNotFoundException(idParentMessage); } Message newMessage = new Message(topic, idParentMessage, owner, title, body, attachment); messageStore.Insert(newMessage); transaction.Commit(); //Notify user for answer NotifyUserReply(parentMessage, newMessage); return(newMessage); } }
public override Message GetMessage(string id) { using (TransactionScope transaction = new TransactionScope(mConfiguration)) { MessageDataStore store = new MessageDataStore(transaction); Message msg = store.FindByKey(id); if (msg == null) { throw new MessageNotFoundException(id); } return(msg); } }