示例#1
0
        public ActionResult ToggleVisibility(int id)
        {
            var post = PostRepository.Get(id);

            if (post.Author.Username == User.Identity.Name || User.IsInRole("Admin"))
            {
                if (!post.Inactive)
                {
                    PostRepository.Deactivate(id);
                }
                else if (post.Inactive)
                {
                    PostRepository.Activate(id);
                }
            }

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