Esempio n. 1
0
        private NewsItem CreateNewsWithBasicProperties(NewsManager manager, string title, string content, string author, string sourceName)
        {
            var newsItem = manager.CreateNewsItem();

            newsItem.Title           = title;
            newsItem.DateCreated     = DateTime.UtcNow;
            newsItem.PublicationDate = DateTime.UtcNow.AddDays(1);
            newsItem.ExpirationDate  = DateTime.UtcNow.AddDays(30);
            newsItem.Author          = author;
            newsItem.Content         = content;
            newsItem.SourceName      = sourceName;
            newsItem.UrlName         = ServerArrangementUtilities.GetFormatedUrlName(title);

            return(newsItem);
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a blog post with specified publication date.
        /// </summary>
        /// <param name="blogPostTitle">The blog post title.</param>
        /// <param name="blogId">The blog id.</param>
        /// <param name="publicationDate">The blog post publication date.</param>
        /// <returns></returns>
        public Guid CreateBlogPostSpecificPublicationDate(string blogPostTitle, Guid blogId, DateTime publicationDate)
        {
            BlogsManager blogsManager = new BlogsManager();

            var blog = blogsManager.GetBlog(blogId);
            var post = blogsManager.CreateBlogPost();

            post.Parent  = blog;
            post.Title   = blogPostTitle;
            post.UrlName = ServerArrangementUtilities.GetFormatedUrlName(blogPostTitle);

            Guid blogPostId = post.Id;

            post.SetWorkflowStatus(blogsManager.Provider.ApplicationName, "Published");
            blogsManager.RecompileAndValidateUrls(blog);
            blogsManager.Lifecycle.PublishWithSpecificDate(post, publicationDate);

            blogsManager.SaveChanges();

            return(blogPostId);
        }