Refactoring

--HG--
branch : dev
This commit is contained in:
Suha Can
2010-12-07 16:47:30 -08:00
parent 2b7b92c439
commit f6cfeb3d66
15 changed files with 42 additions and 46 deletions

View File

@@ -106,18 +106,20 @@ namespace Orchard.Blogs.Commands {
}
foreach ( var item in doc.Descendants("item") ) {
string postName = item.Element("title").Value;
if (item != null) {
string postName = item.Element("title").Value;
Context.Output.WriteLine("Adding post: {0}...", postName.Substring(0, Math.Min(postName.Length, 40)));
var post = _contentManager.New("BlogPost");
post.As<ICommonPart>().Owner = owner;
post.As<ICommonPart>().Container = blog;
var slug = Slugify(postName);
post.As<RoutePart>().Slug = slug;
post.As<RoutePart>().Path = post.As<RoutePart>().GetPathWithSlug(slug);
post.As<RoutePart>().Title = postName;
post.As<BodyPart>().Text = item.Element("description").Value;
_contentManager.Create(post);
Context.Output.WriteLine("Adding post: {0}...", postName.Substring(0, Math.Min(postName.Length, 40)));
var post = _contentManager.New("BlogPost");
post.As<ICommonPart>().Owner = owner;
post.As<ICommonPart>().Container = blog;
var slug = Slugify(postName);
post.As<RoutePart>().Slug = slug;
post.As<RoutePart>().Path = post.As<RoutePart>().GetPathWithSlug(slug);
post.As<RoutePart>().Title = postName;
post.As<BodyPart>().Text = item.Element("description").Value;
_contentManager.Create(post);
}
}