public bool EditPost(string postid, string username, string password, BlogPost post, bool publish) { CheckCredentials(username, password); if (_blogConfig.Blog.Contains(postid)) { BlogPost existingPost = _blogConfig.Blog[postid]; existingPost.Title = post.Title; existingPost.Description = post.Description; existingPost.Excerpt = post.Excerpt; existingPost.ExtendedDescription = post.ExtendedDescription; existingPost.Keywords = post.Keywords; existingPost.AllowComments = post.AllowComments; existingPost.AllowPings = post.AllowPings; if (post.Date != DateTime.MinValue) existingPost.Date = post.Date; if (post.Categories.Length > 0) existingPost.Categories = post.Categories; // ignore post.PingUrls, for now existingPost.Published = publish; _blogConfig.Blog.UpdateBlogPost(existingPost); return true; } else { throw new XmlRpcServerException(404, "BlogConfig post with id " + postid + "was not found"); } }
public string NewPost(string blogid, string username, string password, BlogPost post, bool publish) { CheckBlogId(blogid); CheckCredentials(username, password); post.Published = publish; if (post.Date == DateTime.MinValue) post.Date = DateTime.UtcNow; return _blogConfig.Blog.CreateBlogPost(post); }
public BlogPersist(BlogPost[] blogPosts) { _blogPosts = blogPosts; }
public void UpdateBlogPost(BlogPost existingPost) { using (Lock(true)) { if (!_postTable.ContainsKey(existingPost.Id)) throw new XmlRpcServerException(404, "Cannot edit a post that doesn't exist (was it deleted?)"); // pass-by-value semantics BlogPost clone = existingPost.Clone(); _postTable[existingPost.Id] = clone; for (int i = 0; i < _postList.Count; i++) { if (((BlogPost) _postList[i]).Id == clone.Id) { _postList[i] = clone; break; } } } }
public string CreateBlogPost(BlogPost newPost) { string newId = Guid.NewGuid().ToString("d"); newPost.Id = newId; using (Lock(true)) { Add(newPost.Clone()); } return newId; }