Example #1
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="pTopic"></param>
 /// <param name="pIdParentMessage">Null for the first message</param>
 /// <param name="pOwner"></param>
 /// <param name="pTitle"></param>
 /// <param name="pBody"></param>
 /// <param name="pAttachment"></param>
 public Message(Topic pTopic, string pIdParentMessage,
             string pOwner, string pTitle,
             string pBody, Attachment.FileInfo pAttachment)
 {
     Topic = pTopic;
     Owner = pOwner;
     Title = pTitle;
     Body = pBody;
     IdParentMessage = pIdParentMessage;
     Attachment = pAttachment;
 }
Example #2
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="topic"></param>
 /// <param name="idParentMessage"></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>
 /// <returns></returns>
 public static Message CreateMessage(Topic topic, string idParentMessage, string owner, string title, string body, Attachment.FileInfo attachment)
 {
     return Provider.CreateMessage(topic, idParentMessage, owner, title, body, attachment);
 }
Example #3
0
 public static int MessageCountByTopic(Topic topic)
 {
     return Provider.MessageCountByTopic(topic);
 }
Example #4
0
 /// <summary>
 /// Get a list of messages for the specified topic ordered by InsertDate
 /// </summary>
 /// <param name="topic"></param>
 /// <returns></returns>
 public static IList<Message> GetMessagesByTopic(Topic topic)
 {
     return Provider.GetMessagesByTopic(topic);
 }
Example #5
0
 public static void DeleteTopic(Topic topic)
 {
     Provider.DeleteTopic(topic);
 }
Example #6
0
 /// <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 static void CreateTopic(Category category, string owner,
                                   string title, string body, Attachment.FileInfo attachment,
                                   out Topic topic,
                                   out Message rootMessage)
 {
     Provider.CreateTopic(category, owner, title, body, attachment, out topic, out rootMessage);
 }
Example #7
0
 public abstract int MessageCountByTopic(Topic topic);
Example #8
0
 /// <summary>
 /// Get a list of messages for the specified topic ordered by InsertDate
 /// </summary>
 /// <param name="idTopic"></param>
 /// <returns></returns>
 public abstract IList<Message> GetMessagesByTopic(Topic topic);
Example #9
0
 public abstract void DeleteTopic(Topic topic);
Example #10
0
 /// <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 abstract void CreateTopic(Category category, string owner, 
                                   string title, string body, Attachment.FileInfo attachment,
                                   out Topic topic,
                                   out Message rootMessage);
Example #11
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="topic"></param>
 /// <param name="idParentMessage"></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>
 /// <returns></returns>
 public abstract Message CreateMessage(Topic topic, string idParentMessage, string owner, string title, string body, Attachment.FileInfo attachment);
        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(Configuration))
            {
                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 int MessageCountByTopic(Topic topic)
        {
            using (TransactionScope transaction = new TransactionScope(Configuration))
            {
                MessageDataStore store = new MessageDataStore(transaction);

                return store.MessageCountByTopic(topic);
            }
        }
        /// <summary>
        /// Get a list of messages for the specified topic ordered by InsertDate
        /// </summary>
        /// <param name="topic"></param>
        /// <returns></returns>
        public override IList<Message> GetMessagesByTopic(Topic topic)
        {
            //TODO Evaluate if is better to returns a light object to don't load all the attachments and the forum data

            using (TransactionScope transaction = new TransactionScope(Configuration))
            {
                MessageDataStore store = new MessageDataStore(transaction);

                return store.FindByTopic(topic);
            }
        }
        public override void DeleteTopic(Topic topic)
        {
            using (TransactionScope transaction = new TransactionScope(Configuration))
            {
                TopicDataStore dataStore = new TopicDataStore(transaction);

                dataStore.Delete(topic.Id);

                transaction.Commit();
            }
        }
        /// <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)
        {
            //Check attachment
            if (attachment != null)
                Attachment.FileHelper.CheckFile(attachment, category.AttachExtensions, category.AttachMaxSize);

            using (TransactionScope transaction = new TransactionScope(Configuration))
            {
                CategoryDataStore forumStore = new CategoryDataStore(transaction);
                forumStore.Attach(category);

                //Insert topic
                TopicDataStore topicStore = new TopicDataStore(transaction);
                topic = new Topic(category, owner, title);
                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();
            }
        }