public MP.PostInfo Add(DateTime?created, string title, string desc, IList <string> cats, bool publish) { var p = new MP.PostInfo(); p.DateCreated = created != null ? created.Value : System.DateTime.Now; p.Title = clean_post_title(title); p.Description = desc; p.PostId = System.DateTime.Now.Ticks.ToString(); p.Link = "/post/" + this.TitleToPostId(p.Title); p.Permalink = p.Link; p.PostStatus = "published"; if (cats != null) { if (cats.Any(c => c.Trim().Length < 1)) { throw new System.ArgumentException("Category cannot be empoty or whitespace"); } p.Categories.AddRange(cats); } this.Add(p); return(p); }
public PostInfoRecord(MP.PostInfo p) { this.Title = p.Title; this.Link = p.Link; this.DateCreated = p.DateCreated; this.PostId = p.PostId; this.UserId = p.UserId; this.CommentCount = p.CommentCount; this.PostStatus = p.PostStatus; this.Permalink = p.Permalink; this.Description = p.Description; this.Categories = BlogServer.join_cat_strings(p.Categories.Select(s => s.Trim())); }
public MP.PostInfo ToPostInfo() { var p = new MP.PostInfo(); p.Title = this.Title; p.Link = this.Link; p.DateCreated = this.DateCreated; p.PostId = this.PostId; p.UserId = this.UserId; p.CommentCount = this.CommentCount; p.PostStatus = this.PostStatus; p.Permalink = this.Permalink; p.Description = this.Description; var cats = this.SplitCategories(); foreach (string cat in cats) { p.Categories.Add(cat.Trim()); } return p; }
public MP.PostInfo ToPostInfo() { var p = new MP.PostInfo(); p.Title = this.Title; p.Link = this.Link; p.DateCreated = this.DateCreated; p.PostId = this.PostId; p.UserId = this.UserId; p.CommentCount = this.CommentCount; p.PostStatus = this.PostStatus; p.Permalink = this.Permalink; p.Description = this.Description; var cats = this.SplitCategories(); foreach (string cat in cats) { p.Categories.Add(cat.Trim()); } return(p); }
public void Add(MP.PostInfo p) { this.Dictionary[p.PostId] = new PostInfoRecord(p); this.Dictionary.Flush(); }
/// <summary> /// /// </summary> /// <param name="pi"></param> /// <param name="categories"></param> /// <param name="publish"></param> /// <returns></returns> public async Task <string> NewPost(PostInfo pi, IList <string> categories, bool publish) { return(await NewPost(pi.Title, pi.Description, categories, publish, pi.DateCreated)); }
/// <summary> /// /// </summary> /// <param name="pi"></param> /// <param name="categories"></param> /// <param name="publish"></param> /// <returns></returns> public async Task<string> NewPost(PostInfo pi, IList<string> categories, bool publish) { return await NewPost(pi.Title, pi.Description, categories, publish, pi.DateCreated); }
/// <summary> /// /// </summary> /// <param name="postid"></param> /// <returns></returns> public async Task<PostInfo> GetPost(string postid) { var service = new Service(this.BlogConnectionInfo.MetaWeblogUrl); var method = new MethodCall("metaWeblog.getPost"); method.Parameters.Add(postid); // notice this is the postid, not the blogid method.Parameters.Add(BlogConnectionInfo.Username); method.Parameters.Add(BlogConnectionInfo.Password); var response = await service.Execute(method); var param = response.Parameters[0]; var _struct = (Struct)param; var postinfo = new PostInfo { PostId = _struct.Get<StringValue>("postid").String, Description = _struct.Get<StringValue>("description").String, Link = _struct.Get("link", StringValue.NullString).String, DateCreated = _struct.Get<DateTimeValue>("dateCreated").Data, Permalink = _struct.Get("permaLink", StringValue.NullString).String ?? _struct.Get("permalink", StringValue.NullString).String, PostStatus = _struct.Get("post_status", StringValue.NullString).String, Title = _struct.Get<StringValue>("title").String, UserId = _struct.Get("userid", StringValue.NullString).String }; //item.Categories //item.Tags return postinfo; }