예제 #1
0
        public void Update(int postId)
        {
            ContentPost post = postService.GetById(postId, ctx.owner.Id);

            if (post == null)
            {
                echo(lang("exDataNotFound"));
                return;
            }

            ContentValidator.SetPostValue(post, ctx);
            ContentValidator.ValidateTalk(post, ctx);
            if (errors.HasErrors)
            {
                Edit(postId);
            }
            else
            {
                post.Title = strUtil.SubString(post.Content, 20);
                postService.Update(post, ctx.Post("TagList"));

                echoToParentPart(lang("opok"));
                HtmlHelper.SetPostToContext(ctx, post);
            }
        }
예제 #2
0
        public void Create(int sectionId)
        {
            ContentPost post = ContentValidator.Validate(sectionService.GetById(sectionId, ctx.app.Id), ctx);

            ContentValidator.ValidateTalk(post, ctx);
            if (errors.HasErrors)
            {
                run(Add, sectionId);
            }
            else
            {
                post.CategoryId = PostCategory.Talk;

                postService.Insert(post, null);

                echoToParentPart(lang("opok"));
            }
        }
예제 #3
0
        public void Create(int sectionId)
        {
            ContentPost post = ContentValidator.SetValueBySection(sectionService.GetById(sectionId, ctx.app.Id), ctx);

            ContentValidator.ValidateTalk(post, ctx);
            if (errors.HasErrors)
            {
                run(Add, sectionId);
            }
            else
            {
                post.CategoryId = PostCategory.Talk;
                post.Title      = strUtil.SubString(post.Content, 20);

                postService.Insert(post, ctx.Post("TagList"));

                echoToParentPart(lang("opok"));
                HtmlHelper.SetPostToContext(ctx, post);
            }
        }
예제 #4
0
        public void Update(int postId)
        {
            ContentPost post = postService.GetById(postId, ctx.owner.Id);

            if (post == null)
            {
                echo(lang("exDataNotFound"));
                return;
            }

            ContentValidator.ValidateEdit(post, ctx);
            ContentValidator.ValidateTalk(post, ctx);
            if (errors.HasErrors)
            {
                Edit(postId);
            }
            else
            {
                postService.Update(post, null);

                echoToParentPart(lang("opok"));
            }
        }