The data from cmsContentXml
gets dumped directly into the umbraco.config
file so thankfully these are the same.
To make your code a bit more DRY (you're always saving the document in both the if and the else, try this and update the SaveAndPublish
method to Publish
(and in v7 you can use PublishWithResult
to get a detailed result of the publish action):
contentService.Save(document);
// If publish is true, then save and publish the document
if (publish)
{
contentService.Publish(document);
}
In v7 you could then have a look at the publishResult. If there's something wrong then this will tell you what it is. Most likely it'll just work fine this way though (which could mean that SaveAndPublish is broken, but let's figure out if publishResult has errors).