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); } }
/// <summary> /// Create the topic and the relative root message. /// </summary> /// <param name="category"></param> /// <param name="owner"></param> /// <param name="title"></param> /// <param name="body"></param> /// <param name="attachment">Use null if you don't have any attachment</param> /// <param name="topic">Returns the topic created</param> /// <param name="rootMessage">Returns the message created</param> public override void CreateTopic(Category category, string owner, string title, string body, Attachment.FileInfo attachment, out Topic topic, out Message rootMessage, string groups) { //Check attachment if (attachment != null) { Attachment.FileHelper.CheckFile(attachment, category.AttachExtensions, category.AttachMaxSize); } using (TransactionScope transaction = new TransactionScope(mConfiguration)) { CategoryDataStore forumStore = new CategoryDataStore(transaction); forumStore.Attach(category); //Insert topic TopicDataStore topicStore = new TopicDataStore(transaction); topic = new Topic(category, owner, title); topic.Groups = groups; topicStore.Insert(topic); //Insert root message MessageDataStore messageStore = new MessageDataStore(transaction); rootMessage = new Message(topic, null, owner, title, body, attachment); messageStore.Insert(rootMessage); transaction.Commit(); } }
public override IList <Topic> GetTopics(Category category, PagingInfo paging) { using (TransactionScope transaction = new TransactionScope(mConfiguration)) { TopicDataStore dataStore = new TopicDataStore(transaction); return(dataStore.Find(category, paging)); } }
public override IList <Topic> GetTopics(Category category, DateTime fromDate, DateTime toDate) { using (TransactionScope transaction = new TransactionScope(mConfiguration)) { TopicDataStore dataStore = new TopicDataStore(transaction); return(dataStore.Find(category, fromDate, toDate)); } }
public override void DeleteTopic(Topic topic) { using (TransactionScope transaction = new TransactionScope(mConfiguration)) { TopicDataStore dataStore = new TopicDataStore(transaction); topic.Deleted = true; dataStore.Update(topic); transaction.Commit(); } }
public override Topic GetTopic(string id) { using (TransactionScope transaction = new TransactionScope(mConfiguration)) { TopicDataStore dataStore = new TopicDataStore(transaction); Topic topic = dataStore.FindByKey(id); if (topic == null) { throw new TopicNotFoundException(id); } return(topic); } }