Create and delete taxonomy group from SOM in sharepoint
Create Taxonomy
Group
SPSite site = new SPSite("http://win-5c3g1lanj3k:46908/");
TaxonomySession session = new
TaxonomySession(site);
TermStore termStore = session.TermStores["Managed
Metadata Service"];
Group group = termStore.CreateGroup(TextBox1.Text);
TermSet termSet = group.CreateTermSet(TextBox2.Text);
Term term = termSet.CreateTerm(TextBox3.Text, 1033);
term.SetDescription(TextBox4.Text,
1033);
termStore.CommitAll();
Label4.Text = TextBox1.Text + " - Taxonomy
Group Created Successfully";
Delete Taxonomy
Group
SPSite site = new
SPSite("http://win-5c3g1lanj3k:46908/");
TaxonomySession session = new TaxonomySession(site);
TermStore termStore = session.TermStores["Managed Metadata Service"];
Group group = termStore.Groups[TextBox1.Text];
group.Delete();
termStore.CommitAll();
Label4.Text = TextBox1.Text + " - Taxonomy Group Deleted Successfully";
Label4.ForeColor = System.Drawing.Color.Green;
TextBox1.Text = string.Empty;
TaxonomySession session = new TaxonomySession(site);
TermStore termStore = session.TermStores["Managed Metadata Service"];
Group group = termStore.Groups[TextBox1.Text];
group.Delete();
termStore.CommitAll();
Label4.Text = TextBox1.Text + " - Taxonomy Group Deleted Successfully";
Label4.ForeColor = System.Drawing.Color.Green;
TextBox1.Text = string.Empty;
Comments