本文整理汇总了C#中DotNetNuke.Entities.Content.Taxonomy.TermController.AddTermToContent方法的典型用法代码示例。如果您正苦于以下问题:C# TermController.AddTermToContent方法的具体用法?C# TermController.AddTermToContent怎么用?C# TermController.AddTermToContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DotNetNuke.Entities.Content.Taxonomy.TermController
的用法示例。
在下文中一共展示了TermController.AddTermToContent方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TermController_AddTermToContent_Should_Call_DataService_If_Valid_Params
public void TermController_AddTermToContent_Should_Call_DataService_If_Valid_Params()
{
//Arrange
Mock<IDataService> mockDataService = new Mock<IDataService>();
TermController termController = new TermController(mockDataService.Object);
ContentItem content = ContentTestHelper.CreateValidContentItem();
Term term = ContentTestHelper.CreateValidSimpleTerm(Constants.VOCABULARY_ValidVocabularyId);
// Act
termController.AddTermToContent(term, content);
// Assert
mockDataService.Verify(ds => ds.AddTermToContent(term, content));
}
示例2: 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);
}
}
示例3: TermController_AddTermToContent_Throws_On_Null_ContentItem
public void TermController_AddTermToContent_Throws_On_Null_ContentItem()
{
//Arrange
Mock<IDataService> mockDataService = new Mock<IDataService>();
TermController termController = new TermController(mockDataService.Object);
Term term = ContentTestHelper.CreateValidSimpleTerm(Constants.VOCABULARY_ValidVocabularyId);
//Act, Arrange
AutoTester.ArgumentNull<ContentItem>(content => termController.AddTermToContent(term, content));
}
示例4: TermController_AddTermToContent_Throws_On_Null_Term
public void TermController_AddTermToContent_Throws_On_Null_Term()
{
//Arrange
Mock<IDataService> mockDataService = new Mock<IDataService>();
TermController termController = new TermController(mockDataService.Object);
ContentItem content = ContentTestHelper.CreateValidContentItem();
//Act, Arrange
AutoTester.ArgumentNull<Term>(term => termController.AddTermToContent(term, content));
}
示例5: TermController_AddTermToContent_Throws_On_Null_ContentItem
public void TermController_AddTermToContent_Throws_On_Null_ContentItem()
{
//Arrange
var mockDataService = new Mock<IDataService>();
var termController = new TermController(mockDataService.Object);
Term term = ContentTestHelper.CreateValidSimpleTerm(Constants.VOCABULARY_ValidVocabularyId);
//Act, Arrange
Assert.Throws<ArgumentNullException>(() => termController.AddTermToContent(term, null));
}
示例6: TermController_AddTermToContent_Throws_On_Null_Term
public void TermController_AddTermToContent_Throws_On_Null_Term()
{
//Arrange
var mockDataService = new Mock<IDataService>();
var termController = new TermController(mockDataService.Object);
ContentItem content = ContentTestHelper.CreateValidContentItem();
//Act, Arrange
Assert.Throws<ArgumentNullException>(() => termController.AddTermToContent(null, content));
}
示例7: 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);
}