示例#1
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 ? "审核通过!" : "审核失败!"));
        }