本文整理汇总了C#中DotNetNuke.Entities.Content.Taxonomy.TermController.GetTermsByVocabulary方法的典型用法代码示例。如果您正苦于以下问题:C# TermController.GetTermsByVocabulary方法的具体用法?C# TermController.GetTermsByVocabulary怎么用?C# TermController.GetTermsByVocabulary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DotNetNuke.Entities.Content.Taxonomy.TermController
的用法示例。
在下文中一共展示了TermController.GetTermsByVocabulary方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Init
public static void Init (PortalModuleBase module, DnnComboBox comboWorkingHours)
{
// fill working hours terms
var termCtrl = new TermController ();
var workingHours = termCtrl.GetTermsByVocabulary ("University_WorkingHours").ToList ();
workingHours.Insert (0, new Term (Localization.GetString ("NotSelected.Text", module.LocalResourceFile)));
comboWorkingHours.DataSource = workingHours;
comboWorkingHours.DataBind ();
}
示例2: Exist
public HttpResponseMessage Exist(int vocabularyId, int termId, int parentId, string termName)
{
var exists = false;
var controller = new TermController();
var vocabulary = new VocabularyController().GetVocabularies().FirstOrDefault(v => v.VocabularyId == vocabularyId);
if (vocabulary != null && !string.IsNullOrEmpty(termName))
{
var terms = controller.GetTermsByVocabulary(vocabularyId);
exists = terms.Any(t => t.Name.Equals(termName.Trim(), StringComparison.InvariantCultureIgnoreCase) && t.TermId != termId && (parentId < 0 || t.ParentTermId == parentId));
}
return Request.CreateResponse(HttpStatusCode.OK, exists);
}
示例3: Search
public HttpResponseMessage Search(int vocabularyId, int termId, int parentId, string termName)
{
IList<SearchResult> results = new List<SearchResult>();
var controller = new TermController();
var vocabulary = new VocabularyController().GetVocabularies().FirstOrDefault(v => v.VocabularyId == vocabularyId);
if (vocabulary != null && !string.IsNullOrEmpty(termName))
{
var terms = controller.GetTermsByVocabulary(vocabularyId);
var relatedTerms = terms.Where(t => t.Name.ToLowerInvariant().Contains(termName.Trim().ToLowerInvariant()) && t.TermId != termId && (parentId < 0 || t.ParentTermId == parentId));
foreach (Term term in relatedTerms)
{
results.Add(new SearchResult(){label = term.Name, value = term.Name});
}
}
return Request.CreateResponse(HttpStatusCode.OK, results);
}
示例4: OnInit
/// <summary>
/// Handles Init event for a control.
/// </summary>
/// <param name="e">Event args.</param>
protected override void OnInit (EventArgs e)
{
base.OnInit (e);
// set url for Cancel link
linkCancel.NavigateUrl = Globals.NavigateURL ();
// add confirmation dialog to delete button
buttonDelete.Attributes.Add ("onClick", "javascript:return confirm('" + Localization.GetString ("DeleteItem") + "');");
// parse QueryString
itemId = Utils.ParseToNullableInt (Request.QueryString ["division_id"]);
// fill divisions dropdown
var divisions = DivisionController.GetObjects<DivisionInfo> ()
// exclude current division
.Where (d => (itemId == null || itemId != d.DivisionID)).OrderBy (dd => dd.Title).ToList ();
// insert default item
divisions.Insert (0, DivisionInfo.DefaultItem (LocalizeString ("NotSelected.Text")));
// bind divisions to the tree
treeParentDivisions.DataSource = divisions;
treeParentDivisions.DataBind ();
// init working hours
WorkingHoursLogic.Init (this, comboWorkingHours);
// Fill terms list
// TODO: Org. structure vocabulary name must be set in settings
var termCtrl = new TermController ();
var terms = termCtrl.GetTermsByVocabulary ("University_Structure").ToList ();
// add default term,
// TermId = Null.NullInteger is set in cstor
terms.Insert (0, new Term (Localization.GetString ("NotSelected.Text", LocalResourceFile)));
// bind terms to the tree
treeDivisionTerms.DataSource = terms;
treeDivisionTerms.DataBind ();
}
示例5: 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);
}
}
示例6: TermController_GetTermsByVocabulary_Throws_On_Invalid_VocabularyId
public void TermController_GetTermsByVocabulary_Throws_On_Invalid_VocabularyId()
{
//Arrange
Mock<IDataService> mockDataService = new Mock<IDataService>();
TermController termController = new TermController(mockDataService.Object);
//Act, Arrange
Assert.Throws<ArgumentOutOfRangeException>(() => termController.GetTermsByVocabulary(Null.NullInteger));
}
示例7: TermController_GetTermsByVocabulary_Returns_Terms_On_Valid_VocabularyId
public void TermController_GetTermsByVocabulary_Returns_Terms_On_Valid_VocabularyId()
{
//Arrange
Mock<IDataService> mockDataService = new Mock<IDataService>();
mockDataService.Setup(ds => ds.GetTermsByVocabulary(Constants.TERM_ValidVocabulary1))
.Returns(MockHelper.CreateValidTermsReader(Constants.TERM_ValidCountForVocabulary1,
v => Constants.TERM_ValidVocabulary1,
c => Constants.TERM_ValidContent1));
TermController termController = new TermController(mockDataService.Object);
//Act
List<Term> terms = termController.GetTermsByVocabulary(Constants.TERM_ValidVocabulary1).ToList();
//Assert
Assert.AreEqual(Constants.TERM_ValidCountForVocabulary1, terms.Count);
for (int i = 0; i < Constants.TERM_ValidCountForVocabulary1; i++)
{
Assert.AreEqual(i + Constants.TERM_ValidTermId, terms[i].TermId);
Assert.AreEqual(ContentTestHelper.GetTermName(i + Constants.TERM_ValidTermId), terms[i].Name);
}
}
示例8: TermController_GetTermsByVocabulary_Throws_On_Invalid_VocabularyName
public void TermController_GetTermsByVocabulary_Throws_On_Invalid_VocabularyName()
{
//Arrange
var mockDataService = new Mock<IDataService>();
var termController = new TermController(mockDataService.Object);
//Act, Arrange
Assert.Throws<ArgumentException>(() => termController.GetTermsByVocabulary(Null.NullString));
}
示例9: TermController_GetTermsByVocabulary_Throws_On_Invalid_VocabularyId
public void TermController_GetTermsByVocabulary_Throws_On_Invalid_VocabularyId()
{
//Arrange
var mockDataService = new Mock<IDataService>();
MockComponentProvider.CreateDataProvider().Setup(c=>c.GetProviderPath()).Returns(String.Empty);
var termController = new TermController(mockDataService.Object);
//Act, Arrange
Assert.Throws<ArgumentOutOfRangeException>(() => termController.GetTermsByVocabulary(Null.NullInteger));
}
示例10: 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);
}