/// <summary> /// Delete a comment /// </summary> /// <param name="comment">Comment</param> /// /// <param name="persist">Persist delete</param> public void DeleteComment(Comment comment, bool persist = false) { if (comment == null) throw new ArgumentNullException("comment"); if (!persist && comment.Deleted) return; _commentRepository.Delete(comment, persist); }
/// <summary> /// Inserts a message for comment management /// </summary> /// <param name="comment">The comment to send a message about</param> /// <param name="messageType">The message type to send</param> /// <param name="createdBy">The user who requested moderation of the comment</param> /// <param name="authorMessage">A message to the author of the comment</param> /// <param name="userMessage">A message to the user who flagged the comment</param> public void CommentMessage(Comment comment, MessageType messageType, int createdBy, string authorMessage = "", string userMessage = "") { if (comment == null) throw new ArgumentNullException("comment"); string messageUrl = MessageUrl(); switch (messageType) { case MessageType.CommentRemovalRejected: var message = new MessageQueue { Priority = 30, User = _userService.GetUserById(createdBy), Subject = _siteSettings.TwitterHashTag + " - Comment Moderation", ShortBody = "The comment you flagged has been reviewed " + messageUrl, Body = WrapStringInHtml("The comment you flagged has been mulled over by a moderator and deemed acceptable.") + WrapStringInHtml(userMessage) }; InsertMessageQueue(message); break; case MessageType.CommentRemovalApproved: var message2 = new MessageQueue { Priority = 30, User = _userService.GetUserById(createdBy), Subject = _siteSettings.TwitterHashTag + " - Comment Moderation", ShortBody = "The comment you flagged has been removed " + messageUrl, Body = WrapStringInHtml("The comment you flagged has been removed.") + WrapStringInHtml(userMessage) }; InsertMessageQueue(message2); //var message3 = new MessageQueue //{ // Priority = 30, // User = comment.Author, // Subject = message2.Subject = _hashTag + " - Comment Removal", // ShortBody = "Your comment has been removed from the site. " + messageUrl, // Body = WrapStringInHtml("Your comment '" + comment.UserComment + "' has been removed from the site.") + WrapStringInHtml("We have received complaints from the site users.") + WrapStringInHtml(authorMessage) //}; //InsertMessageQueue(message3); break; } }
public ActionResult PostComment(int id, string commentBody, int inResponseTo) { var project = _projectService.GetProjectById(id); if (project == null) return RedirectToAction("index", "home"); var primaryLocation = project.Locations.First(l => l.Primary).Location; if (!string.IsNullOrEmpty(commentBody)) { if (commentBody.Length > 2000) commentBody = commentBody.Substring(0, 2000); // Build the comment object var comment = new Comment { UserComment = StripProfanity(commentBody.StripHtml()) }; // Set whether the comment is a response if (inResponseTo > 0) comment.InResponseTo = _commentService.GetCommentById(inResponseTo); else comment.Project = project; // Insert the comment record _commentService.InsertComment(comment); TempData.Add(PROJECT_COMMENT_ADDED, true); return new RedirectResult(Url.RouteUrl("ProjectDetail", new { locationSeoName = primaryLocation.GetSeoName(), seoName = project.GetSeoName(), id }) + "#comment-" + comment.Id); } AddNotification(NotifyType.Error, "You didn't enter a comment", true); return new RedirectResult(Url.RouteUrl("ProjectDetail", new { locationSeoName = primaryLocation.GetSeoName(), seoName = project.GetSeoName(), id })); }
public static Comment ToEntity(this CommentModel model) { if (model == null) return null; var entity = new Comment { Active = model.Active, Author = model.Author.ToEntity(), CreatedBy = model.CreatedBy, CreatedDate = model.CreatedDate, Deleted = model.Deleted, Id = model.Id, LastModifiedBy = model.LastModifiedBy, LastModifiedDate = model.LastModifiedDate, ModeratedBy = model.LastModifiedBy, ModeratedDate = model.LastModifiedDate, ModerationRequestCount = model.ModerationRequestCount, Project = model.Project.ToEntity(), UserComment = model.UserComment }; return entity; }
private CommentModel PrepareListCommentModel(Comment comment) { if (comment == null) return null; var model = PrepareCommentModel(comment); model.Actions.Add(new ModelActionLink { Alt = "Edit", Icon = Url.Content("~/Areas/Admin/Content/images/icon-edit.png"), Target = Url.Action("edit", new { id = comment.Id }) }); model.Actions.Add(new DeleteActionLink(comment.Id, Search, Page)); return model; }
private CommentModel PrepareCommentModel(Comment comment) { if (comment == null) return null; var model = comment.ToModel(); model.Project = comment.Project.ToModel(); if (comment.InResponseTo != null) { model.InResponseTo = comment.InResponseTo.ToModel(); model.InResponseTo.Project = comment.InResponseTo.Project.ToModel(); } return model; }
/// <summary> /// Insert a moderation queue item for project comment complaints /// </summary> /// <param name="comment">Comment object</param> /// <param name="type">Type of complaint</param> /// <param name="reason">Reason for complaint</param> public void InsertModerationQueueCommentModeration(Comment comment, ProjectCommentComplaintType type, string reason) { if (comment == null) throw new ArgumentNullException("comment"); var flag = new ProjectCommentModeration { Comment = comment, ComplaintType = type, Reason = reason, ModerationQueue = new ModerationQueue { RequestType = ModerationRequestType.ProjectComment, StatusType = ModerationStatusType.Open, CreatedDate = DateTime.Now, CreatedBy = _workContext.CurrentUser.Id } }; // Increment the comment flag count comment.ModerationRequestCount++; // Insert the new moderation request _moderationQueueProjectCommentModerationRepository.Insert(flag); _commentService.UpdateComment(comment); }
/// <summary> /// Updates the project /// </summary> /// <param name="comment">Comment</param> public void UpdateComment(Comment comment) { if (comment == null) throw new ArgumentNullException("comment"); comment.LastModifiedBy = _workContext.CurrentUser.Id; comment.LastModifiedDate = DateTime.Now; _commentRepository.Update(comment); }
/// <summary> /// Insert a project /// </summary> /// <param name="comment">Comment</param> public void InsertComment(Comment comment) { if (comment == null) throw new ArgumentNullException("comment"); comment.Active = true; comment.Author = _workContext.CurrentUser; comment.CreatedBy = _workContext.CurrentUser.Id; comment.CreatedDate = DateTime.Now; _commentRepository.Insert(comment); }