예제 #1
0
        /// <summary>
        /// This is used to update the content in the ContentItems table. Should be called when a question is updated.
        /// </summary>
        internal void UpdateContentItem(AlbumInfo objAlbum, int tabId)
        {
            var objContent = Util.GetContentController().GetContentItem(objAlbum.ContentItemId);

            if (objContent == null) return;
            objContent.Content = objAlbum.ShortContent;
            objContent.TabID = tabId;
            objContent.ContentKey = "view=" + Constants.PageScope.Question.ToString().ToLower() + "&id=" + objAlbum.AlbumID;

            Util.GetContentController().UpdateContentItem(objContent);

            // Update Terms
            var cntTerm = new Terms();
            cntTerm.ManageQuestionTerms(objAlbum, objContent);
        }
예제 #2
0
        /// <summary>
        /// This should only run after the Post exists in the data store. 
        /// </summary>
        /// <returns>The newly created ContentItemID from the data store.</returns>
        /// <remarks>This is for the first question in the thread. Not for replies or items with ParentID > 0.</remarks>
        internal ContentItem CreateContentItem(AlbumInfo objPost, int tabId)
        {
            var typeController = new ContentTypeController();
            var colContentTypes = (from t in typeController.GetContentTypes() where t.ContentType == Constants.ContentTypeName select t);
            int contentTypeID;

            if (colContentTypes.Count() > 0)
            {
                var contentType = colContentTypes.Single();
                contentTypeID = contentType == null ? CreateContentType() : contentType.ContentTypeId;
            }
            else
            {
                contentTypeID = CreateContentType();
            }

            var objContent = new ContentItem
                                {
                                    Content = objPost.ShortContent,
                                    ContentTypeId = contentTypeID,
                                    Indexed = false,
                                    ContentKey = "view=" + Constants.PageScope.Question.ToString().ToLower() + "&id=" + objPost.AlbumID,
                                    ModuleID = objPost.ModuleID,
                                    TabID = tabId
                                };

            objContent.ContentItemId = Util.GetContentController().AddContentItem(objContent);

            // Add Terms
            var cntTerm = new Terms();
            cntTerm.ManageQuestionTerms(objPost, objContent);

            return objContent;
        }
예제 #3
0
        /// <summary>
        /// This removes a content item associated with a question/thread from the data store. Should run every time an entire thread is deleted.
        /// </summary>
        /// <param name="contentItemID"></param>
        internal void DeleteContentItem(int contentItemID)
        {
            if (contentItemID <= Null.NullInteger) return;
            var objContent = Util.GetContentController().GetContentItem(contentItemID);
            if (objContent == null) return;

            // remove any metadata/terms associated first (perhaps we should just rely on ContentItem cascade delete here?)
            var cntTerms = new Terms();
            cntTerms.RemoveQuestionTerms(objContent);

            Util.GetContentController().DeleteContentItem(objContent);
        }