API for creating blog posts?

Topics: Core, Customizing Orchard, Writing modules
Oct 3, 2013 at 8:58 AM
Hi, I'm a C# developer (although I haven't done any MVC).

I am trying to import a bunch of content from my existing blog into Orchard CMS. None of the import tools are working so I wanted to try writing my own little utility (a console application which executes locally using reference DLLs or something)

Is there some SDK documentation explaining which classes / methods I should be looking for to:
  • Create Blog Posts
  • Add comments
  • Upload media files
That is all I want to achieve. I don't really want to "customise" the product or build any "modules" .. I just want to achieve this quickly as a one-off so I can get on with writing blog posts.

(If this doesn't work then I am probably going to end up on Wordpress .. I'd much rather use Orchard though ;))
Oct 3, 2013 at 7:31 PM
I've created pages in the past as part of my data migration class. Hope this helps...
public class Migrations : DataMigrationImpl
  {

    private readonly IOrchardServices _orchardServices;
    
    public Migrations(IOrchardServices orchardServices)
    {
      _orchardServices = orchardServices;
    }

    public int UpdateFrom1()
    {
      var page = _orchardServices.ContentManager.New("Page");
      page.As<TitlePart>().Title = "Thank You";
      page.As<AutoroutePart>().CustomPattern = "/order-thank-you";
      page.As<AutoroutePart>().UseCustomPattern = true;
      page.As<Orchard.Core.Common.Models.BodyPart>().Text = "Thank you for your order. Please allow us a business day to get back to you.";

      _orchardServices.ContentManager.Create(page);
      _orchardServices.ContentManager.Publish(page);

      return 2;
    }
}