public ActionResult Pass(int id)
        {
            var msg = LeaveMessageService.GetById(id);

            msg.Status = Status.Published;
            bool b = LeaveMessageService.SaveChanges() > 0;

#if !DEBUG
            var pid     = msg.ParentId == 0 ? msg.Id : LeaveMessageService.GetParentMessageIdByChildId(id);
            var content = new Template(System.IO.File.ReadAllText(Path.Combine(HostEnvironment.WebRootPath, "template", "notify.html"))).Set("time", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")).Set("nickname", msg.NickName).Set("content", msg.Content);
            var emails  = LeaveMessageService.GetSelfAndAllChildrenMessagesByParentId(pid).Select(c => c.Email).Except(new List <string> {
                msg.Email, CurrentUser.Email
            }).ToHashSet();
            var link = Url.Action("Index", "Msg", new { cid = pid }, Request.Scheme);
            foreach (var s in emails)
            {
                BackgroundJob.Enqueue(() => CommonHelper.SendMail($"{Request.Host}{CommonHelper.SystemSettings["Title"]} 留言回复:", content.Set("link", link).Render(false), s));
            }
#endif
            return(ResultData(null, b, b ? "审核通过!" : "审核失败!"));
        }
示例#2
0
        public ActionResult Pass(int id)
        {
            var msg = LeaveMessageService.GetById(id);

            msg.Status = Status.Pended;
            bool b = LeaveMessageService.UpdateEntitySaved(msg);

#if !DEBUG
            var    pid     = msg.ParentId == 0 ? msg.Id : LeaveMessageService.GetParentMessageIdByChildId(id);
            string content = System.IO.File.ReadAllText(Path.Combine(_hostingEnvironment.WebRootPath, "template", "notify.html")).Replace("{{time}}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")).Replace("{{nickname}}", msg.NickName).Replace("{{content}}", msg.Content);
            var    emails  = LeaveMessageService.GetSelfAndAllChildrenMessagesByParentId(pid).Select(c => c.Email).Distinct().Except(new List <string>()
            {
                msg.Email
            }).ToList();
            string link = Url.Action("Index", "Msg", new { cid = pid }, Request.Scheme);
            foreach (var s in emails)
            {
                BackgroundJob.Enqueue(() => CommonHelper.SendMail($"{Request.Host}{CommonHelper.SystemSettings["Title"]} 留言回复:", content.Replace("{{link}}", link), string.Join(",", s)));
            }
#endif
            return(ResultData(null, b, b ? "审核通过!" : "审核失败!"));
        }