public ActionResult Block(int id)
        {
            var merge = PostMergeRequestService.GetById(id) ?? throw new NotFoundException("待合并文章未找到");

            merge.MergeState = MergeStatus.Block;
            var b = PostMergeRequestService.SaveChanges() > 0;

            return(b ? ResultData(null, true, "操作成功!") : ResultData(null, false, "操作失败!"));
        }
        public IActionResult Merge([FromForm] PostMergeRequestCommandBase dto)
        {
            var merge = PostMergeRequestService.GetById(dto.Id) ?? throw new NotFoundException("待合并文章未找到");

            Mapper.Map(dto, merge);
            var b = PostMergeRequestService.SaveChanges() > 0;

            return(b ? Merge(merge.Id) : ResultData(null, false, "文章合并失败!"));
        }
        public ActionResult Reject(int id, string reason)
        {
            var merge = PostMergeRequestService.GetById(id) ?? throw new NotFoundException("待合并文章未找到");

            merge.MergeState = MergeStatus.Reject;
            var b = PostMergeRequestService.SaveChanges() > 0;

            if (!b)
            {
                return(ResultData(null, false, "操作失败!"));
            }

            var link    = Request.Scheme + "://" + Request.Host + "/" + merge.Post.Id + "/merge/" + id;
            var content = System.IO.File.ReadAllText(HostEnvironment.WebRootPath + "/template/merge-reject.html").Replace("{{link}}", link).Replace("{{title}}", merge.Post.Title).Replace("{{reason}}", reason);

            BackgroundJob.Enqueue(() => CommonHelper.SendMail(CommonHelper.SystemSettings["Title"] + "博客你提交的修改已被拒绝", content, merge.ModifierEmail));
            return(ResultData(null, true, "合并已拒绝!"));
        }
        public IActionResult Merge(int id)
        {
            var merge   = PostMergeRequestService.GetById(id) ?? throw new NotFoundException("待合并文章未找到");
            var history = merge.Post.Mapper <PostHistoryVersion>();

            history.Id = 0;
            merge.Post = Mapper.Map(merge, merge.Post);
            merge.Post.PostHistoryVersion.Add(history);
            merge.Post.ModifyDate = DateTime.Now;
            merge.MergeState      = MergeStatus.Merged;
            var b = PostMergeRequestService.SaveChanges() > 0;

            if (!b)
            {
                return(ResultData(null, false, "文章合并失败!"));
            }

            string link    = Request.Scheme + "://" + Request.Host + "/" + merge.Post.Id;
            string content = System.IO.File.ReadAllText(HostEnvironment.WebRootPath + "/template/merge-pass.html").Replace("{{link}}", link).Replace("{{title}}", merge.Post.Title);

            BackgroundJob.Enqueue(() => CommonHelper.SendMail(CommonHelper.SystemSettings["Title"] + "博客你提交的修改已通过", content, merge.ModifierEmail));
            return(ResultData(null, true, "文章合并完成!"));
        }