Exemplo n.º 1
0
        private void ApproveBlog(Blog b, string auditor, bool updatetime)
        {
            // if the blog is already disapproved, approving it consider an amend.
            bool amend = b.isApproved == false;

            if (b.isApproved != true)
            {
                b.isApproved = true;
                TriggerApproveBlog(b);
                if (updatetime)
                {
                    b.BlogDate = DateTime.Now;
                }
                _adminUtil.ArchiveAudit(b, auditor, BlogAudit.Action.Approve, amend);
                _adminUtil.log(auditor, "approve", b.BlogID.ToString());
            }
        }
Exemplo n.º 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"));
        }