private void MoveToFolder()
{
DateTime pubDate;
if (DateTime.TryParse(this["PublishedOn"].ToString(), out pubDate))
{
string dateFolderName = String.Format("{0}-{1:00}", pubDate.Year, pubDate.Month);
// check if the post is already in the proper folder
if (this.ParentName == dateFolderName) return;
// check if the proper folder exists
var targetPath = RepositoryPath.Combine(this.WorkspacePath, String.Concat("Posts/", dateFolderName));
if (!Node.Exists(targetPath))
{
// target folder needs to be created
Content.CreateNew("Folder", Node.LoadNode(RepositoryPath.Combine(this.WorkspacePath, "Posts")), dateFolderName).Save();
}
// hide this move from journal
this.NodeOperation = SenseNet.ContentRepository.Storage.NodeOperation.HiddenJournal;
// move blog post to the proper folder
this.MoveTo(Node.LoadNode(targetPath));
Security.HasPermission(User.Current, Node.LoadNode(1), SenseNet.ContentRepository.Storage.Schema.PermissionType.Delete);
}
}