コード例 #1
0
    Post IMetaWeblog.GetPost(string postid, string username, string password)
    {
      if (!authenticationService.Authenticate(username, password))
        throw new XmlRpcFaultException(0, "User is not valid!");

      var blog = blogService.LoadById(int.Parse(postid));

      var post = new Post
                   {
                     postid = blog.Id,
                     title = blog.Title,
                     description = blog.Content,
                     dateCreated = blog.PublishDate.ToUniversalTime(),
                     userid = username,
                     wp_slug = blog.Slug
                   };

      return post;
    }
コード例 #2
0
    bool IMetaWeblog.UpdatePost(string postid, string username, string password,
                                Post post, bool publish)
    {
      if (!authenticationService.Authenticate(username, password))
        throw new XmlRpcFaultException(0, "User is not valid!");

      var blog = blogService.LoadById(int.Parse(postid));

      if (blog.User.Email != username)
        throw new XmlRpcFaultException(0, "User does not have permission to edit this item.");

      blog.Title = post.title;
      blog.Slug = blog.Title.Slug();
      blog.Content = post.description;
      blog.PublishDate = post.dateCreated.Year != 1 ? post.dateCreated.ToUniversalTime() : blog.PublishDate;

      blogService.Save(blog);

      return true;
    }
コード例 #3
0
    string IMetaWeblog.AddPost(string blogid, string username, string password,
                               Post post, bool publish)
    {
      if (!authenticationService.Authenticate(username, password))
        throw new XmlRpcFaultException(0, "User is not valid!");

      var year = post.dateCreated.Year;

      var newPost = new BlogPost
                      {
                        Title = post.title,
                        Content = post.description,
                        PublishDate = year == 1 ? DateTime.Now : post.dateCreated.ToUniversalTime(),
                        CreationDate = DateTime.Now,
                        User = authenticationService.Load(username),
                        Published = false,
                        Slug = post.title.Slug()
                      };

      return blogService.Save(newPost).Id.ToString();
    }