Ejemplo n.º 1
0
        private Post ToMetaWebLogPost(Models.Post post)
        {
            var request = this.context.HttpContext.Request;
            var url     = request.Scheme + "://" + request.Host;

            return(new Post
            {
                postid = post.Id,
                title = post.Title,
                wp_slug = post.Slug,
                permalink = url + post.GetLink(),
                dateCreated = post.PubDate,
                description = post.Content,
                categories = post.Categories.ToArray()
            });
        }
Ejemplo n.º 2
0
        public string AddPost(string blogid, string username, string password, Post post, bool publish)
        {
            ValidateUser(username, password);

            var newPost = new Models.Post
            {
                Title       = post.title,
                Slug        = !string.IsNullOrWhiteSpace(post.wp_slug) ? post.wp_slug : Models.Post.CreateSlug(post.title),
                Content     = post.description,
                IsPublished = publish,
                Categories  = post.categories
            };

            if (post.dateCreated != DateTime.MinValue)
            {
                newPost.PubDate = post.dateCreated;
            }

            this.blog.SavePost(newPost).GetAwaiter().GetResult();

            return(newPost.Id);
        }