Beispiel #1
0
        public object EditPost(string postid, string username, string password, Post sourcePost, bool publish)
        {
            validateRequest(username, password);

            var post = Core.Post.GetPost(postid, _repository);

                        if (post == null)
                            throw new NoSuchPostException(null,postid);

            post.UpdatePost(
                sourcePost.title,
                sourcePost.description,
                true,
                username,
                sourcePost.categories.Select(x => new Tag(x)).ToList()
                );

            Core.Post.Save(post, _repository);

            return true;
        }
Beispiel #2
0
        public Post GetPost(string postid, string username, string password)
        {
            validateRequest(username, password);

            var targetPost = new Post();
            var sourcePost = Core.Post.GetPost(postid, _repository);

                        if (sourcePost == null)
                            throw new NoSuchPostException(null, postid);

            targetPost.postid = sourcePost.Id;
            targetPost.dateCreated = sourcePost.Created;
            targetPost.title = sourcePost.Title;
            targetPost.description = sourcePost.Body;
            targetPost.link = _urlContext.GetPostUrl(sourcePost);
            targetPost.mt_allow_comments = "0"; // or "1"
            targetPost.userid = sourcePost.Author;
            targetPost.categories = sourcePost.Tags.Select(x => x.TagName).ToArray();

            return targetPost;
        }
Beispiel #3
0
        public string NewPost(string blogid, string username, string password, Post sourcePost, bool publish)
        {
            validateRequest(username, password);

            var post = Core.Post.CreatePost(
                sourcePost.title,
                sourcePost.description,
                username,
                sourcePost.categories.Select(x => new Tag(x)).ToList()
                );

            Core.Post.Save(post, _repository);

            return post.Id;
        }
Beispiel #4
0
        public Post[] GetRecentPosts(string blogid, string username, string password, int numberOfPosts)
        {
            validateRequest(username, password);

            var sendPosts = new List<Post>();
            var posts = Core.Post.GetPublishedPosts(_repository).Take(50).ToList();

            // Set End Point
            var stop = numberOfPosts;
            if (stop > posts.Count)
                stop = posts.Count;

            foreach (var post in posts.GetRange(0, stop))
            {

                var tempPost = new Post
                {
                    postid = post.Id,
                    dateCreated = post.Created,
                    title = post.Title,
                    description = post.Body,
                    link = _urlContext.GetPostUrl(post),
                    categories = post.Tags.Select(x => x.TagName).ToArray()
                };

                sendPosts.Add(tempPost);
            }

            return sendPosts.ToArray();
        }
Beispiel #5
0
 public string newPost(string blogid, string username, string password, Post post, bool publish)
 {
     return Inner.NewPost(blogid, username, password, post, publish);
 }
Beispiel #6
0
 public object editPost(string postid, string username, string password, Post post, bool publish)
 {
     return Inner.EditPost(postid, username, password, post, publish);
 }