Using Umbraco 5.1 API,
I am able to create a new content type (for creating content nodes under content tab) using the below code.
// create content type
var typeBuilder = context.Hive.Cms().NewContentType("testType", "Test Type")
.Define("value", "contentPicker", "Content")
.Commit();
// create content node
var packageNode = context.Hive.Cms().NewRevision(packageNodeName, packageNodeName, "testType");
packageNode.SetUploadedFile("value", postedFile);
packageNode.Publish();
packageNode.Commit();
But is there a way to create media node using fluent API? I need to create a new custom media node with a custom type in the media tab tree.
I have tried the below approaches, but none of them seem to work
1) context.Hive.Cms().NewRevision();
2) context.Hive.Cms<IMediaStore>().NewRevision();
3) builderStep.NewRevision<Media, IMediaStore>();
4) builderStep.NewRevision<TypedEntity, IMediaStore>();
This works, but the resulting media type is not complete, as it throws an error “name should be specified” when I try to manually create a media using this type.
Finally I decided to create the media type manually, and use the below code to create media item via code