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;
    }
    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;
    }
    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();
    }