Creating a taxonomy via FeatureEventHandler

Topics: Customizing Orchard
Mar 25, 2014 at 8:05 PM
Hi,

I'm working through Kevin Kuebler from Pluralsight's Advanced Orchard tutorial but it's for version 1.4. I can't seem to get the sample code working for Taxonomy (using Contrib.Taxonomies.Services) What's changed in the new Taxonomy?

public void Enabled(Feature feature)
    {
        // if Genre taxonomy does not exist
        //    create Genre taxonomy
        //    create several genre terms in the taxonomy
        if (_taxonomyService.GetTaxonomyByName("Genre") == null)
        {
            var genre = _contentManager.New<TaxonomyPart>("Taxonomy");
            genre.Name = "Genre";
            _contentManager.Create(genre, VersionOptions.Published);

            CreateTerm(genre, "Action");
            CreateTerm(genre, "Adventure");
            CreateTerm(genre, "Animation");
            CreateTerm(genre, "Comedy");
            CreateTerm(genre, "Crime");
            CreateTerm(genre, "Documentary");
            CreateTerm(genre, "Drama");
        }
    }