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 })); }
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")); }
public ActionResult EditComment(int article, int comment, string body, string name) { var articleModel = ArticleModel.GetArticleById(article); if (articleModel == null) { return(new HttpStatusCodeResult(HttpStatusCode.NotFound)); } var commentModel = CommentModel.GetCommentById(comment); if (commentModel == null) { return(new HttpStatusCodeResult(HttpStatusCode.NotFound)); } if (body == null) { body = commentModel.BodyRaw; name = commentModel.Username; return(View(new EditCommentViewModel { Article = articleModel, Comment = commentModel, Post = new CommentFormModel { Body = body, Name = name } })); } StoredProcs.Comments_CreateOrUpdateComment(comment, article, body, name, commentModel.PublishedDate, commentModel.UserIP, commentModel.UserToken, commentModel.ParentCommentId).ExecuteNonQuery(); return(RedirectToRoute("ArticleCommentsAdmin", new { id = articleModel.Id })); }
public ActionResult ViewArticleById(int id) { var article = ArticleModel.GetArticleById(id); if (article == null) { return(HttpNotFound()); } return(Redirect(article.Url)); }
public ActionResult ViewArticleById(int id, bool onlyBodyAndAdHtml = false) { var article = ArticleModel.GetArticleById(id); if (article == null) { return(ErrorStatus(HttpStatusCode.NotFound, "Invalid Id")); } return(FormatOutput(article, onlyBodyAndAdHtml)); }
public string ViewArticleById(int id, bool onlyBodyAndAdHtml = false) { var article = ArticleModel.GetArticleById(id); if (article == null) { return(ErrorStatus("Invalid Id")); } return(FormatOutput(article, onlyBodyAndAdHtml)); }
public EditArticleViewModel(int?articleId) { if (articleId != null) { this.Article = ArticleModel.GetArticleById((int)articleId); } else { this.Article = new ArticleModel(); } if (this.Article.PublishedDate != null) { this.Date = this.Article.PublishedDate.Value.Date.ToShortDateString(); this.Time = this.Article.PublishedDate.Value.TimeOfDay.ToString(); } }
public EditArticleViewModel(int?articleId) { if (articleId != null) { this.Article = ArticleModel.GetArticleById((int)articleId); } else { this.Article = new ArticleModel(); } if (this.Article.PublishedDate != null) { this.Date = this.Article.PublishedDate.Value.Date.ToShortDateString(); this.Time = this.Article.PublishedDate.Value.TimeOfDay.ToString(); } this.UseCustomSlug = !string.Equals(Regex.Replace(this.Article.Title ?? "", @"[^a-z0-9_]+", "-", RegexOptions.IgnoreCase).Trim('-'), this.Article.Slug ?? "", StringComparison.OrdinalIgnoreCase); }
public ActionResult ArticleComments(int id, int page) { if (this.User == null) { return(new HttpStatusCodeResult(HttpStatusCode.Forbidden)); } var article = ArticleModel.GetArticleById(id); if (article == null) { return(new HttpStatusCodeResult(HttpStatusCode.NotFound)); } if (this.User.IsAdmin) { return(View(new ArticleCommentsViewModel(article, page, true))); } if (this.User.Identity.Name != article.Author.Slug) { return(new HttpStatusCodeResult(HttpStatusCode.Forbidden)); } return(View(new ArticleCommentsViewModel(article, page, false))); }
public ActionResult EditComment(int article, int comment, string body, string name) { var articleModel = ArticleModel.GetArticleById(article); if (articleModel == null) { return(new HttpStatusCodeResult(HttpStatusCode.NotFound)); } var commentModel = CommentModel.GetCommentById(comment); if (commentModel == null) { return(new HttpStatusCodeResult(HttpStatusCode.NotFound)); } if (body == null) { body = commentModel.BodyRaw; name = commentModel.Username; return(View(new EditCommentViewModel { Article = articleModel, Comment = commentModel, Post = new CommentFormModel { Body = body, Name = name } })); } DB.Comments_CreateOrUpdateComment( Article_Id: article, Body_Html: body, User_Name: name, Posted_Date: commentModel.PublishedDate, User_IP: commentModel.UserIP, User_Token: commentModel.UserToken, Parent_Comment_Id: commentModel.ParentCommentId, Comment_Id: comment ); return(RedirectToRoute("ArticleCommentsAdmin", new { id = articleModel.Id })); }