コード例 #1
0
        public bool editPost(string postid, string username, string password, Post post, bool publish)
        {
            ValidateUser(username, password);
            var contentId = GetContentId(postid);

            var content = contentRepository.GetById(contentId);
            var textContent = content as ITextContent;

            if (textContent == null)
            {
                throw new ApplicationException("Invalid post id");
            }

            content.Name = post.title;
            textContent.Text = post.description;
            content.IsActive = publish;

            contentRepository.SubmitChanges();

            return false;
        }
コード例 #2
0
        /// <summary>
        /// Creates a new post.  The publish boolean is used to determine whether the item 
        /// should be published or not.
        /// </summary>
        /// <param name="blogid">The blogid.</param>
        /// <param name="username">The username.</param>
        /// <param name="password">The password.</param>
        /// <param name="post">The post.</param>
        /// <param name="publish">if set to <c>true</c> [publish].</param>
        /// <returns></returns>
        public string newPost(string blogid, string username, string password, Post post, bool publish)
        {
            CreateServices();

            ValidateUser(username, password);

            var parent = menuRepository.GetById(1); // hack assumes that root content has id = 1
            var content = new TextContent
            {
                ParentContent = parent,
                Position = contentOrderableService.NextPosition,
                IsActive = publish,
                Name = post.title,
                Text = post.description
            };

            contentRepository.SaveOrUpdate(content);
            unitOfWorkManager.Commit();

            return content.Id.ToString();
        }
コード例 #3
0
        public bool editPost(string postid, string username, string password, Post post, bool publish)
        {
            CreateServices();

            ValidateUser(username, password);
            int contentId = GetContentId(postid);

            var content = contentRepository.GetById(contentId);
            var textContent = content as ITextContent;

            if (textContent == null)
            {
                throw new XmlRpcFaultException(1, "Invalid post id");
            }

            content.Name = post.title;
            textContent.Text = post.description;
            content.IsActive = publish;

            unitOfWorkManager.Commit();

            return false;

        }
コード例 #4
0
        public void Should_be_able_to_add_a_post()
        {
            Content content = null;

            contentRepository.Expect(r => r.InsertOnSubmit(null)).Callback((Content arg1) =>
            {
                content = arg1;
                return true;
            });

            var post = new Post
            {
                title = "the title",
                description = "the description"
            };

            client.newPost("1", "mike", "m1ke", post, true);

            var textContent = content as TextContent;
            if(textContent == null) Assert.Fail("content should be an instance of TextContent");

            Assert.That(textContent.Name, Is.EqualTo(post.title));
            Assert.That(textContent.Text, Is.EqualTo(post.description));
        }
コード例 #5
0
        public string newPost(string blogid, string username, string password, Post post, bool publish)
        {
            ValidateUser(username, password);

            var content = new TextContent
            {
                ParentContentId = 1,
                Position = contentOrderableService.NextPosition,
                ContentTypeId = ContentType.TextContentId,
                IsActive = publish,
                Name = post.title,
                Text = post.description
            };

            contentRepository.InsertOnSubmit(content);
            contentRepository.SubmitChanges();

            return content.ContentId.ToString();
        }