I'm trying to take a look at Umbraco 5, and trying to figure out how to add content from an outside application. In v4 I would have done something like the following,
var documentType = DocumentType.GetByAlias(UmbracoDocumentType.Country.ToString());
var parentId = DocumentFinder.GetDefaultParentIdForDocumentType(documentType.Alias);
var docs = Document.GetDocumentsOfDocumentType(documentType.Id);
var list = docs.Select(doc => Convert.ToInt32(doc.getProperty("externalId").Value)).ToList();
string name;
Document document;
foreach (DataRow dataRow in dataTable.Rows)
{
if (list.Contains(Convert.ToInt32(dataRow["Id"])))
{
document = DocumentFinder.GetDocumentByExternalId(dataRow.Field<int>("Id"), documentType.Id);
document.getProperty("name").Value = dataRow["Name"].ToString();
}
else
{
name = dataRow["Name"].ToString();
if (name == string.Empty) continue;
document = Document.MakeNew(name, documentType, administratorAsAuthor, parentId);
document.getProperty("externalId").Value = Convert.ToInt32(dataRow["Id"]);
document.getProperty("name").Value = dataRow["Name"].ToString();
}
try
{
document.Save();
}
catch (Exception ex)
{
ExceptionManager.Handle(ex);
}
}
But in v5 there are no such things, and I have searched and searched and found nothing that could help me, even put a post on thier forum, and no responses yet. So, I wanted to post here to see if anyone else might know how this done now.
I know that its still Beta, but I think that there should be a way.
Thanks, Andrew