Esempio n. 1
0
        public IActionResult Merge([FromForm] PostMergeRequestInputDtoBase dto)
        {
            var merge = PostMergeRequestService.GetById(dto.Id) ?? throw new NotFoundException("待合并文章未找到");

            Mapper.Map(dto, merge);
            var b = PostMergeRequestService.UpdateEntitySaved(merge);

            if (b)
            {
                return(Merge(merge.Id));
            }

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

            merge.MergeState = MergeStatus.Reject;
            var b = PostMergeRequestService.UpdateEntitySaved(merge);

            if (b)
            {
                string link    = Request.Scheme + "://" + Request.Host + "/" + merge.Post.Id + "/merge/" + id;
                string content = System.IO.File.ReadAllText(HostingEnvironment.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, "合并已拒绝!"));
            }

            return(ResultData(null, false, "操作失败!"));
        }
Esempio n. 3
0
        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.UpdateEntitySaved(merge);

            if (b)
            {
                string link    = Request.Scheme + "://" + Request.Host + "/" + merge.Post.Id;
                string content = System.IO.File.ReadAllText(HostingEnvironment.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, "文章合并完成!"));
            }

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