Example #1
0
        /// <summary>
        /// This should only run after the Article exists in the data store. 
        /// </summary>
        /// <returns>The newly created ContentItemID from the data store.</returns>
        public ContentItem CreateContentItem(Article objArticle, int tabId)
        {
            var typeController = new ContentTypeController();
            var colContentTypes = (from t in typeController.GetContentTypes() where t.ContentType == 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 = objArticle.Title + " " + HttpUtility.HtmlDecode(objArticle.Description),
                ContentTypeId = contentTypeId,
                Indexed = false,
                ContentKey = "aid=" + objArticle.ArticleId,
                ModuleID = objArticle.ModuleId,
                TabID = tabId
            };

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

            // Add Terms
            var cntTerm = new Terms();
            cntTerm.ManageArticleTerms(objArticle, objContent);

            return objContent;
        }
Example #2
0
        /// <summary>
        /// This removes a content item associated with an article from the data store. Should run every time an article is deleted.
        /// </summary>
        /// <param name="objArticle">The Content Item we wish to remove from the data store.</param>
        public void DeleteContentItem(Article objArticle)
        {
            if (objArticle.ContentItemId <= Null.NullInteger) return;
            var objContent = Util.GetContentController().GetContentItem(objArticle.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.RemoveArticleTerms(objArticle);

            Util.GetContentController().DeleteContentItem(objContent);
        }
Example #3
0
        /// <summary>
        /// This is used to update the content in the ContentItems table. Should be called when an Article is updated.
        /// </summary>
        public void UpdateContentItem(Article objArticle, int tabId)
        {
            var objContent = Util.GetContentController().GetContentItem(objArticle.ContentItemId);

            if (objContent == null) return;
            objContent.Content = objArticle.Title + " " + HttpUtility.HtmlDecode(objArticle.Description);
            objContent.TabID = tabId;

            //testing meta data code
            //Util.GetContentController().DeleteMetaData(objContent, "Description", objArticle.Description);
            //Util.GetContentController().AddMetaData(objContent, "Description", objArticle.Description);

            Util.GetContentController().UpdateContentItem(objContent);

            // Update Terms
            var cntTerm = new Terms();
            cntTerm.ManageArticleTerms(objArticle, objContent);
        }