string IMetaWeblog.newPost(string blogid, string username, string password, PostInfo postInfo, bool publish) { AssertCredentials(username, password); var user = securityService.GetAdministrator(username, password); var post = postFactory.Create(postInfo.title, CreatePostText(postInfo.description, postInfo.mt_text_more), user); post.SaveAndFlush(); return post.Id.ToString(); }
private static PostInfo PostToPostInfo(NewsPost post) { PostInfo postInfo = new PostInfo(); List<string> categories = new List<string>(); postInfo.categories = categories.ToArray(); postInfo.dateCreated = post.PostDate; postInfo.description = post.Text.Split(MoreDelimiter.ToCharArray())[0]; if (post.Text.IndexOf(MoreDelimiter) > -1) postInfo.mt_text_more = post.Text.Split(MoreDelimiter.ToCharArray())[1]; postInfo.title = post.Title; postInfo.permalink = GetBlogUrl() + "/Home/Detail.aspx?Id=" + post.Id; postInfo.postid = post.Id.ToString(); return postInfo; }
object IMetaWeblog.editPost(string postid, string username, string password, PostInfo postInfo, bool publish) { AssertCredentials(username, password); long postId = long.Parse(postid); using(new SessionScope()) { NewsPost post = NewsPost.Find(postId); if (post == null) throw new ApplicationException("Post not found"); post.Title = postInfo.title; post.Text = CreatePostText(postInfo.description, postInfo.mt_text_more); post.SaveAndFlush(); } return true; }