Exemplo n.º 1
0
        public CookComputing.MetaWeblog.Post getPost(string postid, string username, string password)
        {
            string folderName;
            string userKey;
            string contentId  = MetaWeblogHelper.ParsePostId(postid, out folderName, out userKey);
            var    textFolder = new TextFolder(Repository, FolderHelper.SplitFullName(folderName));
            var    content    = textFolder.CreateQuery().WhereEquals("UUID", contentId).First();

            return(new CookComputing.MetaWeblog.Post()
            {
                postid = postid,
                categories = GetCategories(textFolder, content),
                description = content["description"] == null ? content["body"] == null ? "" : content["body"].ToString() : content["description"].ToString(),
                title = content["title"] == null ? "" : content["title"].ToString(),
                userid = content.UserId
            });
        }
Exemplo n.º 2
0
        public object editPost(string postid, string username, string password, CookComputing.MetaWeblog.Post post, bool publish)
        {
            CheckUserPassword(username, password);
            string folderName;
            string userKey;
            string contentId  = MetaWeblogHelper.ParsePostId(postid, out folderName, out userKey);
            var    textFolder = new TextFolder(Repository, FolderHelper.SplitFullName(folderName));
            var    content    = textFolder.CreateQuery().WhereEquals("UUID", contentId).First();


            var values = new NameValueCollection();

            values["title"]       = post.title;
            values["description"] = post.description;
            values["body"]        = post.description;
            values["userKey"]     = userKey;
            values["published"]   = publish.ToString();

            ServiceFactory.GetService <TextContentManager>().Update(Repository, textFolder, content.UUID, values, username);


            var old_categories = GetCategories(textFolder, content);

            var removedCategories = old_categories.Where(it => !post.categories.Any(c => string.Compare(c, it, true) == 0));
            var addedCategories   = post.categories.Where(it => !old_categories.Any(c => string.Compare(c, it, true) == 0));

            var removed = GetCategories(textFolder, removedCategories).ToArray();

            if (removed.Length > 0)
            {
                ServiceFactory.GetService <TextContentManager>().RemoveCategories(Repository, (TextContent)content, removed);
            }

            var added = GetCategories(textFolder, addedCategories).ToArray();

            if (added.Length > 0)
            {
                ServiceFactory.GetService <TextContentManager>().AddCategories(Repository, (TextContent)content, added);
            }

            return(MetaWeblogHelper.CompositePostId(content));
        }