Esempio n. 1
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 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();
            }
        }
Esempio n. 2
0
        public override IList <Category> GetAllCategories()
        {
            using (TransactionScope transaction = new TransactionScope(mConfiguration))
            {
                CategoryDataStore dataStore = new CategoryDataStore(transaction);

                return(dataStore.FindAll());
            }
        }
Esempio n. 3
0
 public override void DeleteCategory(Category category)
 {
     using (TransactionScope transaction = new TransactionScope(mConfiguration))
     {
         CategoryDataStore dataStore = new CategoryDataStore(transaction);
         category.Deleted = true;
         category.Name   += DateTimeHelper.GetCurrentTimestamp();
         dataStore.Update(category);
         transaction.Commit();
     }
 }
Esempio n. 4
0
        public override void UpdateCategory(Category category)
        {
            using (TransactionScope transaction = new TransactionScope(mConfiguration))
            {
                CategoryDataStore dataStore = new CategoryDataStore(transaction);

                dataStore.Update(category);

                transaction.Commit();
            }
        }
Esempio n. 5
0
        public override Category GetCategory(string id)
        {
            using (TransactionScope transaction = new TransactionScope(mConfiguration))
            {
                CategoryDataStore dataStore = new CategoryDataStore(transaction);

                Category category = dataStore.FindByKey(id);
                if (category == null)
                {
                    throw new ForumCategoryNotFoundException(id);
                }

                return(category);
            }
        }
Esempio n. 6
0
        public override Category CreateCategory(string name, string displayName)
        {
            using (TransactionScope transaction = new TransactionScope(mConfiguration))
            {
                CategoryDataStore dataStore = new CategoryDataStore(transaction);

                Category category = new Category(name, displayName);

                dataStore.Insert(category);

                transaction.Commit();

                return(category);
            }
        }
Esempio n. 7
0
        public override Category GetCategoryByName(string name, bool throwIfNotFound)
        {
            using (TransactionScope transaction = new TransactionScope(mConfiguration))
            {
                CategoryDataStore dataStore = new CategoryDataStore(transaction);

                Category category = dataStore.FindByName(name);
                if (category == null && throwIfNotFound)
                {
                    throw new ForumCategoryNotFoundException(name);
                }
                else if (category == null)
                {
                    return(null);
                }

                return(category);
            }
        }