/// <summary> /// This is used to update the content in the ContentItems table. Should be called when an item is updated. /// </summary> internal void UpdateContentItem(EntityInfo objEntity, int tabId) { var objContent = Util.GetContentController().GetContentItem(objEntity.ContentItemId); if (objContent == null) return; objContent.TabID = tabId; objContent.ContentKey = "view=" + Constants.PageScope.Detail.ToString().ToLower() + "&id=" + objEntity.Id; Util.GetContentController().UpdateContentItem(objContent); // Update Terms var cntTerm = new Terms(); cntTerm.ManageQuestionTerms(objEntity, objContent); }
/// <summary> /// This should only run after the Item exists in the data store. /// </summary> /// <param name="objEntity"></param> /// <param name="tabId"></param> /// <returns></returns> internal ContentItem CreateContentItem(EntityInfo objEntity, 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 { ContentTypeId = contentTypeID, Indexed = false, ContentKey = "view=" + Constants.PageScope.Detail.ToString().ToLower() + "&id=" + objEntity.Id, ModuleID = objEntity.ModuleID, TabID = tabId }; objContent.ContentItemId = Util.GetContentController().AddContentItem(objContent); // Add Terms var cntTerm = new Terms(); cntTerm.ManageQuestionTerms(objEntity, objContent); return objContent; }
/// <summary> /// This removes a content item associated with a question/thread from the data store. Should run every time an item 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); }