Ejemplo n.º 1
0
        // GET: Post/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Post post = postHelper.GetById(id.Value);

            if (post == null)
            {
                return(HttpNotFound());
            }

            if (!post.isActive)
            {
                if (!LoggedIn())
                {
                    if (!isAuthor() || !isAdmin())
                    {
                        return(RedirectToAction("Index", "Home"));
                    }
                }
            }

            Author author = authorHelper.GetById(post.AuthorId);

            ViewBag.isAnonymous = author.isAnonymous;
            ViewBag.AuthorEmail = author.Email;
            ViewBag.Categories  = categoryHelper.GetAll().Where(c => c.isActive);
            return(View(post));
        }
Ejemplo n.º 2
0
        public ActionResult DeactivatePost(int id)
        {
            if (!LoggedIn())
            {
                return(RedirectToAction("LoginAdmin", "Auth"));
            }

            if (!isAdmin())
            {
                return(RedirectToAction("Index", "Author"));
            }

            Post post = postHelper.GetById(id);

            post.isActive = false;
            postHelper.Update(post);

            return(RedirectToAction("Index", "Admin"));
        }