1
votes

I've written the following simple command inside my module. The Faq type has one custom part with a single field, and one BodyPart. After _cm.Create(item) is run, the item has an Id assigned but I can't find any trace of it in the database and it doesn't appear in Orchard's content tab. Why does the item get an Id but isn't found in the database? And does it need a driver, view, and placement info before it appears in the content tab?

public class ApiCommands : DefaultOrchardCommandHandler
{
    private readonly IContentManager _cm;

    public ApiCommands(IContentManager cm)
    {
        _cm = cm;
    }

    [CommandName("api seed")]
    public void Seed()
    {
        var item = _cm.New("Faq");
        item.As<FaqPart>().Question = "Why is the sky blue?";
        item.As<BodyPart>().Text = "Shut up and do your homework.";

        _cm.Create(item);
    }
}

My custom part has no driver this is the Handler:

public FaqHandler(IRepository<FaqPartRecord> repository)
{
    Filters.Add(StorageFilter.For(repository));
}
1
Please provide the full code of the handler.Bertrand Le Roy
Modified the question to contain the entire handlerBC.

1 Answers

0
votes

It turns out my type didn't attach a CommonPart. After I attached one and set the Owner property of the part, I was able to save it.