Attach existing Content Part to Content Type programmaticaly in controller?

Topics: Core, General, Writing modules
Sep 10, 2013 at 10:38 AM
I nee to attach existing Content Part to Content Type programmaticaly in controller? How can i do that?
Thanks in advance!
Sep 10, 2013 at 10:59 AM
Sorry for such a quick question - found the solution myself ...
private readonly IContentDefinitionManager _contentDefinitionManager;
public TempController(
            IContentDefinitionManager contentDefinitionManager)
        {
            _contentDefinitionManager = contentDefinitionManager;
        }
_contentDefinitionManager.AlterTypeDefinition("YourContentType", x => x.WithPart("ContentPart"));