Beispiel #1
0
        public ActionResult UnfeatureComment(FeatureCommentViewModel post)
        {
            if (this.User == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.Forbidden));
            }
            if (post.Article == null || post.Comment == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var article = ArticleModel.GetArticleById((int)post.Article);

            if (article == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.NotFound));
            }
            if (!this.User.IsAdmin && this.User.Identity.Name != article.Author.Slug)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.Forbidden));
            }
            if (!DB.Articles_UnfeatureComment(article.Id, post.Comment).Value)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            return(RedirectToRoute("ArticleCommentsAdmin", new { id = article.Id }));
        }
Beispiel #2
0
        public ActionResult ApproveComment(FeatureCommentViewModel post)
        {
            if (this.User == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.Forbidden));
            }
            if (post.Article == null || post.Comment == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var article = ArticleModel.GetArticleById((int)post.Article);

            if (article == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.NotFound));
            }
            if (!this.User.IsAdmin && this.User.Identity.Name != article.Author.Slug)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.Forbidden));
            }
            if (!DB.Articles_ApproveComment(article.Id, post.Comment).Value)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            if (!string.IsNullOrEmpty(Request.QueryString["no-redirect"]))
            {
                return(new HttpStatusCodeResult(HttpStatusCode.Accepted));
            }
            return(RedirectToRoute("CommentModerationAdmin"));
        }