コード例 #1
0
        public async Task <JsonResult> EditPost(int cid, string title,
                                                string content, string banner,
                                                string excerpt, int allowcomment,
                                                int status, int type,
                                                int index,
                                                string[] category, string[] tags,
                                                int[] files)
        {
            var result = new ResultModel();

            var post = new Contents();

            if (cid > 0)
            {
                post = await cms.GetByCidAsync(cid);

                Alert.Content = "内容已更新";
            }
            else
            {
                post.createtime = DateTime.Now;
                Alert.Content   = "内容创建成功";
            }
            post.title        = title;
            post.content      = content;
            post.banner       = banner;
            post.excerpt      = excerpt;
            post.index        = index;
            post.allowcomment = allowcomment;
            post.status       = status;
            post.type         = type;
            post.updatetime   = DateTime.Now;
            //写入数据库
            await cms.UpdateAsync(post);

            //对文章内容更新分类和标签
            if (type == 0)
            {
                //更新分类
                await cms.UpdateMetasByCidAsync(post.cid, category, 0);

                //更新标签
                await cms.UpdateMetasByCidAsync(post.cid, tags, 1);
            }

            //更新附件
            await fms.UpdateByCidAsync(post.cid, files);

            result.issuccess = true;

            return(Json(result));
        }