public static ContentPage CreateWPContentPage(WordPressSite wps, WordPressPost c, SiteData site)
{
ContentPage cont = null;
ContentPageType.PageType contType = ContentPageType.PageType.Unknown;
switch (c.PostType)
{
case WordPressPost.WPPostType.BlogPost:
contType = ContentPageType.PageType.BlogEntry;
break;
case WordPressPost.WPPostType.Page:
contType = ContentPageType.PageType.ContentEntry;
break;
}
if (c != null)
{
cont = new ContentPage(site.SiteID, contType);
cont.ContentID = Guid.NewGuid();
cont.CreateUserId = SecurityData.CurrentUserGuid;
cont.EditUserId = SecurityData.CurrentUserGuid;
if (!String.IsNullOrEmpty(c.PostAuthor))
{
WordPressUser wpu = wps.Authors.Where(x => x.Login.ToLower() == c.PostAuthor.ToLower()).FirstOrDefault();
if (wpu != null && wpu.ImportUserID != Guid.Empty)
{
ApplicationUser usr = SecurityData.GetUserByID(wpu.ImportUserID.ToString());
if (usr != null)
{
cont.CreateUserId = wpu.ImportUserID;
cont.EditUserId = wpu.ImportUserID;
}
}
}
cont.Root_ContentID = c.ImportRootID;
cont.FileName = c.ImportFileName.Replace("//", "/");
cont.PageSlug = null;
cont.NavOrder = c.PostOrder;
cont.Parent_ContentID = null;
cont.CreateDate = site.ConvertUTCToSiteTime(c.PostDateUTC);
cont.PageActive = c.IsPublished;
cont.ContentType = ContentPageType.PageType.Unknown;
if (c.PostType == WordPressPost.WPPostType.BlogPost)
{
cont.ContentType = ContentPageType.PageType.BlogEntry;
cont.PageSlug = c.ImportFileSlug.Replace("//", "/");
cont.NavOrder = SiteData.BlogSortOrderNumber;
cont.Parent_ContentID = null;
}
if (c.PostType == WordPressPost.WPPostType.Page)
{
cont.ContentType = ContentPageType.PageType.ContentEntry;
}
if (cont.ContentType == ContentPageType.PageType.ContentEntry)
{
cont.ShowInSiteMap = true;
cont.ShowInSiteNav = true;
}
else
{
cont.ShowInSiteMap = false;
cont.ShowInSiteNav = false;
}
cont.IsLatestVersion = true;
cont.IsLatestVersion = true;
cont.TitleBar = c.PostTitle;
cont.NavMenuText = c.PostTitle;
cont.PageHead = c.PostTitle;
cont.PageText = c.PostContent;
cont.LeftPageText = String.Empty;
cont.RightPageText = String.Empty;
cont.MetaDescription = String.Empty;
cont.MetaKeyword = String.Empty;
cont.ContentCategories = new List <ContentCategory>();
cont.ContentTags = new List <ContentTag>();
List <ContentTag> lstTags = site.GetTagList();
List <ContentCategory> lstCategories = site.GetCategoryList();
cont.ContentCategories = (from l in lstCategories
join o in c.Categories on l.CategorySlug.ToLower() equals o.ToLower()
select l).Distinct().ToList();
cont.ContentTags = (from l in lstTags
join o in c.Tags on l.TagSlug.ToLower() equals o.ToLower()
select l).Distinct().ToList();
}
return(cont);
}