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; }
private static void ImportDocumentLibraryCategories() { VocabularyController vocabularyController = new VocabularyController(); var defaultTags = (from v in vocabularyController.GetVocabularies() where v.IsSystem && v.Name == "Tags" select v).SingleOrDefault(); DataProvider dataProvider = DataProvider.Instance(); dataProvider.ExecuteNonQuery("ImportDocumentLibraryCategories", defaultTags.VocabularyId); }
public void VocabularyController_GetVocabularies_Returns_List_Of_Vocabularies() { //Arrange var mockDataService = new Mock<IDataService>(); mockDataService.Setup(ds => ds.GetVocabularies()).Returns(MockHelper.CreateValidVocabulariesReader(Constants.VOCABULARY_ValidCount)); var vocabularyController = new VocabularyController(mockDataService.Object); //Act IQueryable<Vocabulary> vocabularys = vocabularyController.GetVocabularies(); //Assert Assert.AreEqual(Constants.VOCABULARY_ValidCount, vocabularys.Count()); }
public void VocabularyController_GetVocabularies_Calls_DataService() { //Arrange Mock<IDataService> mockDataService = new Mock<IDataService>(); mockDataService.Setup(ds => ds.GetVocabularies()) .Returns(MockHelper.CreateValidVocabulariesReader(Constants.VOCABULARY_ValidCount)); VocabularyController vocabularyController = new VocabularyController(mockDataService.Object); //Act IQueryable<Vocabulary> vocabularys = vocabularyController.GetVocabularies(); //Assert mockDataService.Verify(ds => ds.GetVocabularies()); }