예제 #1
0
        public async Task <ActionResult> UnApprove(int blogid, int page = 1, bool sendmsg = false, bool delete = false, string MsgContent = "")
        {
            Blog b = _db.Blogs.Find(blogid);

            if (b != null)
            {
                MsgContent = WebUtility.HtmlEncode(MsgContent);
                if (delete)
                {
                    _adminUtil.ArchiveAudit(b, User.Identity.Name, BlogAudit.Action.Deny, b.isApproved == true, MsgContent);
                    await _blogUtil.DeleteBlogAsync(b.BlogID, MsgContent);

                    if (sendmsg)
                    {
                        _msgUtil.AddMsg(User.Identity.Name, b.Author, "删除通知", MsgContent);
                    }
                }
                else
                {
                    DenyBlog(b, User.Identity.Name, sendmsg, MsgContent);
                    _db.SaveChanges();
                }
                return(new EmptyResult());
            }
            return(NotFound());
        }
예제 #2
0
        public async Task <ActionResult> AdminDelete(int id, string MsgContent, bool sendmsg = false, bool unapprove = false)
        {
            Blog b = _db.Blogs.Find(id);

            if (b != null)
            {
                if (unapprove)
                {
                    string user  = User.Identity.Name;
                    bool   amend = b.isApproved == true;
                    if (b.isApproved != false)
                    {
                        b.isApproved = false;
                        _db.SaveChanges();
                        _adminUtil.ArchiveAudit(b, user, BlogAudit.Action.Deny, amend, MsgContent);
                    }
                    if (sendmsg)
                    {
                        _msgUtil.SendUnapproveNotice(b.Author, user, MsgContent, Url.Action("Details", new { id = b.BlogID }));
                    }
                    _adminUtil.log(User.Identity.Name, "reject", b.BlogID.ToString(), MsgContent);
                }
                else
                {
                    if (sendmsg)
                    {
                        _msgUtil.SendDeleteBlogNotice(b.Author, User.Identity.Name, MsgContent, b.BlogTitle);
                    }
                    await _blogUtil.DeleteBlogAsync(id, MsgContent);
                }
                TriggerDeleteBlog(b, !unapprove);
            }
            if (unapprove)
            {
                return(RedirectToAction("Details", new { id = b.BlogID }));
            }
            return(RedirectToAction("List"));
        }