public static Vocabulary CreateValidVocabulary() { Vocabulary vocabulary = new Vocabulary { Name = Constants.VOCABULARY_ValidName, Type = Constants.VOCABULARY_ValidType, ScopeTypeId = Constants.VOCABULARY_ValidScopeTypeId, ScopeId = Constants.VOCABULARY_ValidScopeId, Weight = Constants.VOCABULARY_ValidWeight }; return vocabulary; }
public int AddVocabulary(Vocabulary vocabulary) { //Argument Contract Requires.NotNull("vocabulary", vocabulary); Requires.PropertyNotNullOrEmpty("vocabulary", "Name", vocabulary.Name); Requires.PropertyNotNegative("vocabulary", "ScopeTypeId", vocabulary.ScopeTypeId); vocabulary.VocabularyId = _DataService.AddVocabulary(vocabulary, UserController.GetCurrentUserInfo().UserID); //Refresh Cache DataCache.RemoveCache(_CacheKey); return vocabulary.VocabularyId; }
public void BindVocabulary(Vocabulary vocabulary, bool editEnabled, bool showScope) { if (IsPostBack) { vocabulary.Name = nameTextBox.Text; vocabulary.Description = descriptionTextBox.Text; var scopeTypeController = new ScopeTypeController(); ScopeType scopeType; scopeType = scopeTypeController.GetScopeTypes().Where(s => s.ScopeType == scopeList.SelectedValue).SingleOrDefault(); vocabulary.ScopeTypeId = scopeType.ScopeTypeId; vocabulary.Type = typeList.SelectedValue == "Simple" ? VocabularyType.Simple : VocabularyType.Hierarchy; } else { nameTextBox.Text = vocabulary.Name; nameLabel.Text = vocabulary.Name; descriptionTextBox.Text = vocabulary.Description; typeList.Items.FindByValue(vocabulary.Type.ToString()).Selected = true; if (vocabulary.ScopeType != null) { scopeLabel.Text = Localization.GetString(vocabulary.ScopeType.ScopeType, LocalResourceFile); scopeList.Items.FindByValue(vocabulary.ScopeType.ScopeType).Selected = true; } typeLabel.Text = vocabulary.Type.ToString(); } nameTextBox.Visible = IsAddMode; nameLabel.Visible = !IsAddMode; descriptionTextBox.Enabled = editEnabled; divScope.Visible = (IsAddMode && showScope); scopeLabel.Visible = !(IsAddMode && showScope); typeList.Visible = IsAddMode; typeLabel.Visible = !IsAddMode; }
public void DeleteVocabulary(Vocabulary vocabulary) { //Argument Contract Requires.NotNull("vocabulary", vocabulary); Requires.PropertyNotNegative("vocabulary", "VocabularyId", vocabulary.VocabularyId); _DataService.DeleteVocabulary(vocabulary); //Refresh Cache DataCache.RemoveCache(_CacheKey); }
public void UpdateVocabulary(Vocabulary vocabulary) { //Argument Contract Requires.NotNull("vocabulary", vocabulary); Requires.PropertyNotNegative("vocabulary", "VocabularyId", vocabulary.VocabularyId); Requires.PropertyNotNullOrEmpty("vocabulary", "Name", vocabulary.Name); //Refresh Cache DataCache.RemoveCache(_CacheKey); _DataService.UpdateVocabulary(vocabulary, UserController.GetCurrentUserInfo().UserID); }
public void VocabularyController_DeleteVocabulary_Throws_On_Negative_VocabularyId() { //Arrange var mockDataService = new Mock<IDataService>(); var vocabularyController = new VocabularyController(mockDataService.Object); Vocabulary vocabulary = new Vocabulary(); vocabulary.VocabularyId = Null.NullInteger; //Act, Arrange Assert.Throws<ArgumentOutOfRangeException>(() => vocabularyController.DeleteVocabulary(vocabulary)); }
/// <summary> /// Updates the vocabulary. /// </summary> /// <param name="vocabulary">The vocabulary.</param> /// <param name="lastModifiedByUserId">The last modified by user id.</param> public void UpdateVocabulary(Vocabulary vocabulary, int lastModifiedByUserId) { _provider.ExecuteNonQuery("UpdateVocabulary", vocabulary.VocabularyId, vocabulary.Type, vocabulary.Name, vocabulary.Description, vocabulary.Weight, vocabulary.ScopeId, vocabulary.ScopeTypeId, lastModifiedByUserId); }
/// <summary> /// Deletes the vocabulary. /// </summary> /// <param name="vocabulary">The vocabulary.</param> public void DeleteVocabulary(Vocabulary vocabulary) { _provider.ExecuteNonQuery("DeleteVocabulary", vocabulary.VocabularyId); }
/// <summary> /// Adds the vocabulary. /// </summary> /// <param name="vocabulary">The vocabulary.</param> /// <param name="createdByUserId">The created by user id.</param> /// <returns>Vocabulary id.</returns> public int AddVocabulary(Vocabulary vocabulary, int createdByUserId) { return _provider.ExecuteScalar<int>("AddVocabulary", vocabulary.Type, vocabulary.Name, vocabulary.Description, vocabulary.Weight, _provider.GetNull(vocabulary.ScopeId), vocabulary.ScopeTypeId, createdByUserId); }
private void AddTerms(Vocabulary v, ArrayList terms) { ITermController termRep = Util.GetTermController(); //Add a dummy parent term if simple vocabulary if (v.Type == VocabularyType.Simple) { terms.Add(new { termId = -v.VocabularyId, name = v.Name, parentTermId = Null.NullInteger}); } foreach (Term t in termRep.GetTermsByVocabulary(v.VocabularyId)) { if (v.Type == VocabularyType.Simple) { t.ParentTermId = -v.VocabularyId; } terms.Add(new { termId = t.TermId, name = t.Name, parentTermId = t.ParentTermId }); } }
private void AddTerms(Vocabulary v) { ITermController termRep = Util.GetTermController(); //Add a dummy parent term if simple vocabulary if (v.Type == VocabularyType.Simple) { Term dummyTerm = new Term(v.VocabularyId); dummyTerm.ParentTermId = null; dummyTerm.Name = v.Name; dummyTerm.TermId = -v.VocabularyId; _terms.Add(dummyTerm); } foreach (Term t in termRep.GetTermsByVocabulary(v.VocabularyId)) { if (v.Type == VocabularyType.Simple) { t.ParentTermId = -v.VocabularyId; } _terms.Add(t); } }
public void UpdateVocabulary(Vocabulary vocabulary, int lastModifiedByUserId) { DataRow[] row = vocabularyTable.Select("VocabularyID = " + vocabulary.VocabularyId.ToString()); if (row.Length > 0) { row[0]["Name"] = vocabulary.Name; row[0]["Weight"] = vocabulary.Weight; } }
public Vocabulary GetVocabularyFromTable(int vocabularyId) { Vocabulary vocabulary = null; DataRow[] row = vocabularyTable.Select("VocabularyID = '" + vocabularyId + "'"); if (row.Length > 0) { vocabulary = new Vocabulary(); vocabulary.VocabularyId = vocabularyId; vocabulary.Name = (string)row[0]["Name"]; vocabulary.Type = ((int)row[0]["VocabularyTypeID"] == 1) ? VocabularyType.Simple : VocabularyType.Hierarchy; vocabulary.Description = (string)row[0]["Description"]; vocabulary.ScopeId = (int)row[0]["ScopeID"]; vocabulary.ScopeTypeId = (int)row[0]["ScopeTypeID"]; vocabulary.Weight = (int)row[0]["Weight"]; } return vocabulary; }
public void DeleteVocabulary(Vocabulary vocabulary) { DataRow[] row = vocabularyTable.Select("VocabularyID = " + vocabulary.VocabularyId.ToString()); //Remove the row from the table if (row.Length > 0) { vocabularyTable.Rows.Remove(row[0]); } }
public int AddVocabulary(Vocabulary vocabulary, int createdByUserId) { return Constants.VOCABULARY_AddVocabularyId; }