Exemple #1
0
        /// <summary>
        /// 提交创建
        /// </summary>
        public void Create_POST()
        {
            ArchiveDto archive = default(ArchiveDto);

            var form = HttpContext.Current.Request.Form;

            string alias = form["Alias"];

            if (alias != "")
            {
                if (!ServiceCall.Instance.ArchiveService.CheckArchiveAliasAvailable(this.SiteId, -1, alias))
                {
                    base.RenderError("别名已经存在!");
                    return;
                }
            }


            archive.ViewCount   = 1;
            archive.PublisherId = UserState.Administrator.Current.Id;

            archive = GetFormCopyedArchive(this.SiteId, form, archive, alias);
            JR.Cms.DataTransfer.Result r = ServiceCall.Instance.ArchiveService.SaveArchive(
                this.SiteId, archive.Category.ID, archive);
            if (r.ErrCode > 0)
            {
                base.RenderError(r.ErrMsg);
            }
            else
            {
                //返回文章ID
                base.RenderSuccess(r.Data["ArchiveId"].ToString());
            }
        }
Exemple #2
0
        public void Update_POST()
        {
            var        form    = HttpContext.Current.Request.Form;
            ArchiveDto archive = ServiceCall.Instance.ArchiveService
                                 .GetArchiveById(this.SiteId, int.Parse(form["Id"]));

            //判断是否有权修改
            if (!ArchiveUtility.CanModifyArchive(this.SiteId, archive.PublisherId))
            {
                base.RenderError("您无权修改此文档!");
                return;
            }

            string alias = String.IsNullOrEmpty(form["Alias"]) ?
                           String.Empty :
                           HttpContext.Current.Server.UrlEncode(form["Alias"]);

            if (alias != String.Empty && archive.Alias != alias)
            {
                if (!ServiceCall.Instance.ArchiveService
                    .CheckArchiveAliasAvailable(this.SiteId, archive.Id, alias))
                {
                    base.RenderError("别名已经存在!");
                    return;
                }
            }

            archive = GetFormCopyedArchive(this.SiteId, form, archive, alias);
            JR.Cms.DataTransfer.Result r = ServiceCall.Instance.ArchiveService.SaveArchive(
                this.SiteId, archive.Category.ID, archive);
            if (r.ErrCode > 0)
            {
                base.RenderError(r.ErrMsg);
            }
            else
            {
                //返回文章ID
                base.RenderSuccess("保存成功");
            }
        }