当前位置: 首页>>代码示例>>C#>>正文


C# TermController.AddTerm方法代码示例

本文整理汇总了C#中DotNetNuke.Entities.Content.Taxonomy.TermController.AddTerm方法的典型用法代码示例。如果您正苦于以下问题:C# TermController.AddTerm方法的具体用法?C# TermController.AddTerm怎么用?C# TermController.AddTerm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DotNetNuke.Entities.Content.Taxonomy.TermController的用法示例。


在下文中一共展示了TermController.AddTerm方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Update

        public static string Update (DnnComboBox comboWorkingHours, string workingHours, bool addToVocabulary)
        {
            workingHours = workingHours.Trim ();
            var workingHoursNonEmpty = !string.IsNullOrWhiteSpace (workingHours);

            if (comboWorkingHours.SelectedIndex <= 0 || workingHoursNonEmpty)
            {
                // REVIEW: Shouldn't we try to add term after updating main item?
                if (addToVocabulary && workingHoursNonEmpty)
                {
                    // try add new term to University_WorkingHours vocabulary
                    var vocCtrl = new VocabularyController ();
                    var voc = vocCtrl.GetVocabularies ().SingleOrDefault (v => v.Name == "University_WorkingHours");
                    if (voc != null)
                    {
                        var termCtrl = new TermController ();
                        termCtrl.AddTerm (new Term (workingHours, "", voc.VocabularyId)); 
                        vocCtrl.ClearVocabularyCache ();
                    }
                }

                return workingHours;
            }

            // else: get working hours from a combo
            return comboWorkingHours.SelectedItem.Text;
        }
开发者ID:hassangas2003,项目名称:R7.University,代码行数:27,代码来源:WorkingHoursLogic.cs

示例2: TermController_AddTerm_Throws_On_Null_Term

        public void TermController_AddTerm_Throws_On_Null_Term()
        {
            //Arrange
            var mockDataService = new Mock<IDataService>();
            var termController = new TermController(mockDataService.Object);

            //Act, Arrange
            Assert.Throws<ArgumentNullException>(() => termController.AddTerm(null));
        }
开发者ID:biganth,项目名称:Curt,代码行数:9,代码来源:TermControllerTests.cs

示例3: ImportDocumentLibraryCategoryAssoc

        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);
            }
        }
开发者ID:VegasoftTI,项目名称:Dnn.Platform,代码行数:40,代码来源:Upgrade.cs

示例4: TermController_AddTerm_Throws_On_Null_Term

        public void TermController_AddTerm_Throws_On_Null_Term()
        {
            //Arrange
            Mock<IDataService> mockDataService = new Mock<IDataService>();
            TermController termController = new TermController(mockDataService.Object);

            //Act, Arrange
            AutoTester.ArgumentNull<Term>(term => termController.AddTerm(term));
        }
开发者ID:neogic,项目名称:DotNetNuke_SVN,代码行数:9,代码来源:TermControllerTests.cs

示例5: TermController_AddTerm_Throws_On_Negative_VocabularyId

        public void TermController_AddTerm_Throws_On_Negative_VocabularyId()
        {
            //Arrange
            Mock<IDataService> mockDataService = new Mock<IDataService>();
            TermController termController = new TermController(mockDataService.Object);

            Term term = ContentTestHelper.CreateValidSimpleTerm(Null.NullInteger);

            //Act, Arrange
            Assert.Throws<ArgumentException>(() => termController.AddTerm(term));
        }
开发者ID:neogic,项目名称:DotNetNuke_SVN,代码行数:11,代码来源:TermControllerTests.cs

示例6: TermController_AddTerm_Throws_On_Invalid_Term

        public void TermController_AddTerm_Throws_On_Invalid_Term()
        {
            //Arrange
            Mock<IDataService> mockDataService = new Mock<IDataService>();
            TermController termController = new TermController(mockDataService.Object);

            Term term = ContentTestHelper.CreateValidSimpleTerm(Constants.VOCABULARY_ValidVocabularyId);
            term.Name = Constants.TERM_InValidName;

            //Act, Arrange
            Assert.Throws<ArgumentException>(() => termController.AddTerm(term));
        }
开发者ID:neogic,项目名称:DotNetNuke_SVN,代码行数:12,代码来源:TermControllerTests.cs

示例7: TermController_AddTerm_Should_Call_DataService_AddSimpleTerm_If_Term_Is_Simple_Term

        public void TermController_AddTerm_Should_Call_DataService_AddSimpleTerm_If_Term_Is_Simple_Term()
        {
            //Arrange
            Mock<IDataService> mockDataService = new Mock<IDataService>();
            TermController termController = new TermController(mockDataService.Object);

            Term term = ContentTestHelper.CreateValidSimpleTerm(Constants.VOCABULARY_ValidVocabularyId);

            // Act
            int termId = termController.AddTerm(term);

            // Assert
            mockDataService.Verify(ds => ds.AddSimpleTerm(term, UserController.GetCurrentUserInfo().UserID));
        }
开发者ID:neogic,项目名称:DotNetNuke_SVN,代码行数:14,代码来源:TermControllerTests.cs

示例8: TermController_AddTerm_Sets_Valid_Id_On_Valid_Term_If_Term_Is_Simple_Term

        public void TermController_AddTerm_Sets_Valid_Id_On_Valid_Term_If_Term_Is_Simple_Term()
        {
            //Arrange
            Mock<IDataService> mockDataService = new Mock<IDataService>();
            TermController termController = new TermController(mockDataService.Object);
            mockDataService.Setup(ds => ds.AddSimpleTerm(It.IsAny<Term>(), It.IsAny<int>()))
                .Returns(Constants.TERM_AddTermId);

            Term term = ContentTestHelper.CreateValidSimpleTerm(Constants.VOCABULARY_ValidVocabularyId);

            //Act
            termController.AddTerm(term);

            //Assert
            Assert.AreEqual(Constants.TERM_AddTermId, term.TermId);
        }
开发者ID:neogic,项目名称:DotNetNuke_SVN,代码行数:16,代码来源:TermControllerTests.cs

示例9: TermController_AddTerm_Returns_Valid_Id_On_Valid_Term_If_Term_Is_Heirarchical_Term

        public void TermController_AddTerm_Returns_Valid_Id_On_Valid_Term_If_Term_Is_Heirarchical_Term()
        {
            //Arrange
            Mock<IDataService> mockDataService = new Mock<IDataService>();
            TermController termController = new TermController(mockDataService.Object);
            mockDataService.Setup(ds => ds.AddHeirarchicalTerm(It.IsAny<Term>(), It.IsAny<int>()))
                .Returns(Constants.TERM_AddTermId);

            Term term = ContentTestHelper.CreateValidHeirarchicalTerm(Constants.VOCABULARY_HierarchyVocabularyId,
                                                                      Constants.TERM_ValidParentTermId);

            //Act
            int termId = termController.AddTerm(term);

            //Assert
            Assert.AreEqual(Constants.TERM_AddTermId, termId);
        }
开发者ID:neogic,项目名称:DotNetNuke_SVN,代码行数:17,代码来源:TermControllerTests.cs

示例10: TermController_AddTerm_Clears_Term_Cache_On_Valid_Term

        public void TermController_AddTerm_Clears_Term_Cache_On_Valid_Term()
        {
            //Arrange
            Mock<IDataService> mockDataService = new Mock<IDataService>();
            TermController termController = new TermController(mockDataService.Object);

            Term term = ContentTestHelper.CreateValidSimpleTerm(Constants.VOCABULARY_ValidVocabularyId);

            //Act
            termController.AddTerm(term);

            //Assert
            mockCache.Verify(
                cache => cache.Remove(String.Format(Constants.TERM_CacheKey, Constants.VOCABULARY_ValidVocabularyId)));
        }
开发者ID:neogic,项目名称:DotNetNuke_SVN,代码行数:15,代码来源:TermControllerTests.cs

示例11: TermController_AddTerm_Should_Call_DataService_AddHeirarchicalTerm_If_Term_Is_Heirarchical_Term

        public void TermController_AddTerm_Should_Call_DataService_AddHeirarchicalTerm_If_Term_Is_Heirarchical_Term()
        {
            //Arrange
            var mockDataService = new Mock<IDataService>();
            var termController = new TermController(mockDataService.Object);

            Term term = ContentTestHelper.CreateValidHeirarchicalTerm(Constants.VOCABULARY_HierarchyVocabularyId, Constants.TERM_ValidParentTermId);

            // Act
            int termId = termController.AddTerm(term);

            // Assert
            mockDataService.Verify(ds => ds.AddHeirarchicalTerm(term, UserController.GetCurrentUserInfo().UserID));
        }
开发者ID:biganth,项目名称:Curt,代码行数:14,代码来源:TermControllerTests.cs

示例12: SaveTags

        private void SaveTags()
        {
            string tags = new PortalSecurity().InputFilter(_Tags, PortalSecurity.FilterFlag.NoMarkup | PortalSecurity.FilterFlag.NoScripting);
            tags = HttpContext.Current.Server.HtmlEncode(tags);
            if (!string.IsNullOrEmpty(tags))
            {
                foreach (string t in tags.Split(','))
                {
                    if (!string.IsNullOrEmpty(t))
                    {
                        string tagName = t.Trim(' ');
                        Term existingTerm = (from term in ContentItem.Terms.AsQueryable() where term.Name.Equals(tagName, StringComparison.CurrentCultureIgnoreCase) select term).SingleOrDefault();

                        if (existingTerm == null)
                        {
                            //Not tagged
                            TermController termController = new TermController();
                            Term term =
                                (from te in termController.GetTermsByVocabulary(TagVocabulary.VocabularyId) where te.Name.Equals(tagName, StringComparison.CurrentCultureIgnoreCase) select te).
                                    SingleOrDefault();
                            if (term == null)
                            {
                                //Add term
                                term = new Term(TagVocabulary.VocabularyId);
                                term.Name = tagName;
                                termController.AddTerm(term);
                            }

                            //Add term to content
                            ContentItem.Terms.Add(term);
                            termController.AddTermToContent(term, ContentItem);
                        }
                    }
                }
            }

            IsEditMode = false;

            //Raise the Tags Updated Event
            OnTagsUpdate(EventArgs.Empty);
        }
开发者ID:hungnt-me,项目名称:Dnn.Platform,代码行数:41,代码来源:Tags.cs


注:本文中的DotNetNuke.Entities.Content.Taxonomy.TermController.AddTerm方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。