コード例 #1
0
		/// <summary>
		/// Adds the type of the content.
		/// </summary>
		/// <param name="contentType">Type of the content.</param>
		/// <returns>content type id.</returns>
		/// <exception cref="System.ArgumentNullException">content type is null.</exception>
		/// <exception cref="System.ArgumentException">contentType.ContentType is empty.</exception>
        public int AddContentType(ContentType contentType)
        {
            //Argument Contract
            Requires.NotNull("contentType", contentType);
            Requires.PropertyNotNullOrEmpty("contentType", "ContentType", contentType.ContentType);

            contentType.ContentTypeId = _DataService.AddContentType(contentType);

            //Refresh cached collection of types
            ClearContentTypeCache();

            return contentType.ContentTypeId;
        }
コード例 #2
0
        public void DataService_AddContentType_Adds_Record_On_Valid_ContentType()
        {
            //Arrange
            int rowCount = DataUtil.GetRecordCount(DataTestHelper.ConnectionString,
                                                   ContentDataTestHelper.ContentTypesTableName);
            DataUtil.AddDatabaseObject(virtualScriptFilePath, addContentType);

            ContentType contentType = new ContentType();
            contentType.ContentType = Constants.CONTENTTYPE_ValidContentType;

            DataService ds = new DataService();

            //Act
            int contentTypeItemId = ds.AddContentType(contentType);

            //Assert
            DatabaseAssert.RecordCountIsEqual(DataTestHelper.ConnectionString,
                                              ContentDataTestHelper.ContentTypesTableName, rowCount + 1);
        }
コード例 #3
0
        private static ContentItem CreateFileContentItem()
        {
            var typeController = new ContentTypeController();
            var contentTypeFile = (from t in typeController.GetContentTypes() where t.ContentType == "File" select t).SingleOrDefault();

            if (contentTypeFile == null)
            {
                contentTypeFile = new ContentType { ContentType = "File" };
                contentTypeFile.ContentTypeId = typeController.AddContentType(contentTypeFile);
            }

            var objContent = new ContentItem
            {
                ContentTypeId = contentTypeFile.ContentTypeId,
                Indexed = false,
            };

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

            return objContent;
        }
コード例 #4
0
ファイル: Upgrade.cs プロジェクト: VegasoftTI/Dnn.Platform
        private static void ImportDocumentLibraryCategoryAssoc(ContentType fileContentType)
        {
            DataProvider dataProvider = DataProvider.Instance();
            IDataReader dr;
            try
            {
                dr = dataProvider.ExecuteReader("ImportDocumentLibraryCategoryAssoc");
                var termController = new TermController();
                var vocabulary = new VocabularyController().GetVocabularies().Single(v => v.Name == "Tags");
                var terms = termController.GetTermsByVocabulary(vocabulary.VocabularyId);

                while (dr.Read())
                {
                    var file = FileManager.Instance.GetFile((int)dr["FileId"]);
                    ContentItem attachContentItem;
                    if (file.ContentItemID == Null.NullInteger)
                    {
                        attachContentItem = CreateFileContentItem();
                        file.ContentItemID = attachContentItem.ContentItemId;
                        FileManager.Instance.UpdateFile(file);
                    }
                    else
                    {
                        attachContentItem = Util.GetContentController().GetContentItem(file.ContentItemID);
                    }

                    var term = terms.SingleOrDefault(t => t.Name == dr["CategoryName"].ToString());
                    if (term == null)
                    {
                        term = new Term(dr["CategoryName"].ToString(), null, vocabulary.VocabularyId);
                        termController.AddTerm(term);
                    }
                    termController.AddTermToContent(term, attachContentItem);
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
            }
        }
コード例 #5
0
		/// <summary>
		/// Updates the type of the content.
		/// </summary>
		/// <param name="contentType">Type of the content.</param>
		/// <exception cref="System.ArgumentNullException">content type is null.</exception>
		/// <exception cref="System.ArgumentOutOfRangeException">content type id is less than 0.</exception>
		/// <exception cref="System.ArgumentException">contentType.ContentType is empty.</exception>
        public void UpdateContentType(ContentType contentType)
        {
            //Argument Contract
            Requires.NotNull("contentType", contentType);
            Requires.PropertyNotNegative("contentType", "ContentTypeId", contentType.ContentTypeId);
            Requires.PropertyNotNullOrEmpty("contentType", "ContentType", contentType.ContentType);

            _DataService.UpdateContentType(contentType);

            //Refresh cached collection of types
            ClearContentTypeCache();
        }
コード例 #6
0
ファイル: Content.cs プロジェクト: rut5949/Dnn.Platform
        /// <summary>
        /// Creates a Content Type (for taxonomy) in the data store.
        /// </summary>
        /// <returns>The primary key value of the new ContentType.</returns>
        private static int CreateContentType(string ContentTypeName) {
            var typeController = new ContentTypeController();
            var objContentType = new ContentType { ContentType = ContentTypeName };

            return typeController.AddContentType(objContentType);
        }
コード例 #7
0
        /// <summary>
        /// Creates a unique content type for this module
        /// </summary>
        /// <returns></returns>
        private static int CreateContentType()
        {
            var typeController = new ContentTypeController();
            var objContentType = new ContentType { ContentType = MODULE_TYPE_NAME };

            return typeController.AddContentType(objContentType);
        }
コード例 #8
0
 internal static ContentType CreateValidContentType()
 {
     ContentType contentType = new ContentType {ContentType = Constants.CONTENTTYPE_ValidContentType};
     return contentType;
 }
コード例 #9
0
        private static void CreateContentItem(DesktopModuleInfo desktopModule)
        {
            IContentTypeController typeController = new ContentTypeController();
            ContentType contentType = (from t in typeController.GetContentTypes()
                                       where t.ContentType == "DesktopModule"
                                       select t).SingleOrDefault();

            if (contentType == null)
            {
                contentType = new ContentType { ContentType = "DesktopModule" };
                contentType.ContentTypeId = typeController.AddContentType(contentType);
            }

            IContentController contentController = Util.GetContentController();
            desktopModule.Content = desktopModule.FriendlyName;
            desktopModule.Indexed = false;
            desktopModule.ContentTypeId = contentType.ContentTypeId;
            desktopModule.ContentItemId = contentController.AddContentItem(desktopModule);
        }
コード例 #10
0
 /// <summary>Get a list of content items by ContentType.</summary>
 public IQueryable<ContentItem> GetContentItemsByContentType(ContentType contentType)
 {
     return CBO.FillQueryable<ContentItem>(_dataService.GetContentItemsByContentType(contentType.ContentTypeId));
 }
コード例 #11
0
 /// <summary>Get a list of content items by ContentType.</summary>
 /// <returns></returns>
 public IQueryable <ContentItem> GetContentItemsByContentType(ContentType contentType)
 {
     return(this.GetContentItemsByContentType(contentType.ContentTypeId));
 }
コード例 #12
0
		/// <summary>
		/// Deletes the type of the content.
		/// </summary>
		/// <param name="contentType">Type of the content.</param>
		/// <exception cref="System.ArgumentNullException">content type is null.</exception>
		/// <exception cref="System.ArgumentOutOfRangeException">content type id is less than 0.</exception>
        public void DeleteContentType(ContentType contentType)
        {
            //Argument Contract
            Requires.NotNull("contentType", contentType);
            Requires.PropertyNotNegative("contentType", "ContentTypeId", contentType.ContentTypeId);

            _DataService.DeleteContentType(contentType);

            //Refresh cached collection of types
            DataCache.RemoveCache(_CacheKey);
        }
コード例 #13
0
 public int AddContentType(ContentType contentType)
 {
     return Constants.CONTENTTYPE_AddContentTypeId;
 }
コード例 #14
0
 public void UpdateContentType(ContentType contentType)
 {
 }
コード例 #15
0
 public void DeleteContentType(ContentType contentType)
 {
 }