Skip to main content
2 of 2
replaced http://meta.stackexchange.com/ with https://meta.stackexchange.com/

Example Question:


**Title:** How can I publish an item programatically?
**Body:**

I have a custom import job that takes data from a CSV file and imports them into an Item Bucket.

When the job ends, I need to publish all the items that have been created.

What I have so far:

Here is the code that I use to import:

public class CsvImport() 
{
    public void Process(string csvPath)
    {
        var data = ReadCsvFile(csvPath);
        var importedItems = new List<Item>();
        
        foreach(var row in data)
        {
            var newItem = ImportRow(row);
        }
        
        // TODO: Publish those items that are imported:
    }
    
    private List<IRow> ReadCsvFile(string csvPath)
    {
        //....
    }
    
    private List<Item> ImportItem(IRow row)
    {
        //....
    }
}

What is the best option here? Should I use PublishManager or another method?


What Makes This Good?

* The title contains a simple to the point question * The body adds detail to the question in the title * There is an example of what the OP has tried * Code examples have syntax highlighting enabled ([How to add Syntax Highlighting][1]) * Class names, variables etc... in the body of the text have been marked as a `Code Block` * There are headings for important things