コード例 #1
0
        public string AddPost(string blogid, string username, string password, Post post, bool publish)
        {
            if (MembershipService.ValidateUser(username, password))
            {
                var user = UserRepository.Load(username);

                var blog = BlogRepository.New();
                blog.Entry = post.description;
                blog.Title = post.title;
                blog.IsPublished = publish;
                blog.AuthorID = user.UniqueKey;

                var savedEntry = BlogRepository.Save(blog);

                return savedEntry.UniqueKey.ToString();;
            }
            throw new XmlRpcFaultException(0, "User is not valid");
        }
コード例 #2
0
        public Post GetPost(string postid, string username, string password)
        {
            if (MembershipService.ValidateUser(username, password))
            {
                var blog = BlogRepository.Load(Convert.ToInt32(postid));
                if (blog == null)
                    throw new XmlRpcFaultException(0, "Not an existing post");

                Post post = new Post();
                post.title = blog.Title;
                post.description = blog.Entry;
                post.postid = postid;
                if (blog.IsPublished)
                    post.dateCreated = blog.DatePublished.Value;

                return post;
            }
            throw new XmlRpcFaultException(0, "User is not valid");
        }
コード例 #3
0
        public bool UpdatePost(string postid, string username, string password, Post post, bool publish)
        {
            if (MembershipService.ValidateUser(username, password))
            {
                var blog = BlogRepository.Load(Convert.ToInt32(postid));
                if (blog == null)
                    throw new XmlRpcFaultException(0, "Not an existing post");

                blog.Entry = post.description;
                blog.Title = post.title;
                blog.IsPublished = publish;

                BlogRepository.Save(blog);

                return true;
            }
            throw new XmlRpcFaultException(0, "User is not valid");
        }