public async Task <ActionResult> Block(int id) { var merge = await PostMergeRequestService.GetByIdAsync(id) ?? throw new NotFoundException("待合并文章未找到"); merge.MergeState = MergeStatus.Block; var b = await PostMergeRequestService.SaveChangesAsync() > 0; return(b ? ResultData(null, true, "操作成功!") : ResultData(null, false, "操作失败!")); }
public async Task <IActionResult> Merge([FromForm] PostMergeRequestCommandBase dto) { var merge = await PostMergeRequestService.GetByIdAsync(dto.Id) ?? throw new NotFoundException("待合并文章未找到"); Mapper.Map(dto, merge); var b = await PostMergeRequestService.SaveChangesAsync() > 0; return(b ? await Merge(merge.Id) : ResultData(null, false, "文章合并失败!")); }
public async Task <ActionResult> Reject(int id, string reason) { var merge = await PostMergeRequestService.GetByIdAsync(id) ?? throw new NotFoundException("待合并文章未找到"); merge.MergeState = MergeStatus.Reject; var b = await PostMergeRequestService.SaveChangesAsync() > 0; if (!b) { return(ResultData(null, false, "操作失败!")); } var link = Request.Scheme + "://" + Request.Host + "/" + merge.Post.Id + "/merge/" + id; var content = new Template(await System.IO.File.ReadAllTextAsync(HostEnvironment.WebRootPath + "/template/merge-reject.html")).Set("link", link).Set("title", merge.Post.Title).Set("reason", reason).Render(); BackgroundJob.Enqueue(() => CommonHelper.SendMail(CommonHelper.SystemSettings["Title"] + "博客你提交的修改已被拒绝", content, merge.ModifierEmail, "127.0.0.1")); return(ResultData(null, true, "合并已拒绝!")); }
public async Task <IActionResult> Merge(int id) { var merge = await PostMergeRequestService.GetByIdAsync(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 = await PostMergeRequestService.SaveChangesAsync() > 0; if (!b) { return(ResultData(null, false, "文章合并失败!")); } string link = Request.Scheme + "://" + Request.Host + "/" + merge.Post.Id; string content = new Template(await System.IO.File.ReadAllTextAsync(HostEnvironment.WebRootPath + "/template/merge-pass.html")).Set("link", link).Set("title", merge.Post.Title).Render(); BackgroundJob.Enqueue(() => CommonHelper.SendMail(CommonHelper.SystemSettings["Title"] + "博客你提交的修改已通过", content, merge.ModifierEmail, "127.0.0.1")); return(ResultData(null, true, "文章合并完成!")); }