예제 #1
0
        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();
        }
예제 #2
0
 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;
 }
예제 #3
0
        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;
        }