コード例 #1
0
        public static ProjectCommentModerationModel ToModel(this ProjectCommentModeration entity)
        {
            if (entity == null)
                return null;

            var model = new ProjectCommentModerationModel
            {
                Id = entity.Id,
                Comment = entity.Comment.ToModel(),
                ComplaintId = entity.ComplaintId,
                ComplaintType = entity.ComplaintType,
                TypeDescription = entity.ComplaintType.GetDescription(),
                ModerationQueue = entity.ModerationQueue.ToModel(),
                Reason = entity.Reason
            };

            return model;
        }
コード例 #2
0
        public ActionResult Remove(int id, bool type, ProjectCommentModerationModel form)
        {
            if (!_permissionService.Authorize(PermissionProvider.ManageProjects))
                throw new ArgumentException("Invalid permissions.");

            // Get the queue
            var queue = _moderationQueueService.GetProjectCommentModerationByModerationQueueId(id);
            if (queue == null || queue.Deleted)
                return RedirectToAction("index", "moderation");

            // Get the comment
            var comment = queue.Comment;
            if (comment == null)
                return RedirectToAction("index");

            var model = queue.ToModel();

            try
            {
                if (type)
                {
                    comment.ModeratedBy = _workContext.CurrentUser.Id;
                    comment.ModeratedDate = DateTime.Now;
                    comment.Deleted = true;

                    // Update the comment entity
                    _commentService.UpdateComment(comment);

                    // Create a success notification
                    SuccessNotification("The comment has been removed.");

                    // Send message to the comment flagger
                    _messageQueueService.CommentMessage(comment, MessageType.CommentRemovalApproved, queue.ModerationQueue.CreatedBy, form.ModerationQueue.Notes, form.UserMessage);

                    // Remove outstanding comment complaints if any are in the queue as the comment has been deleted.
                    _moderationQueueService.RemoveAllProjectCommentModerationEntriesByCommentId(comment.Id, model.ModerationQueue.Id);
                }
                else
                {
                    comment.ModeratedBy = _workContext.CurrentUser.Id;
                    comment.ModeratedDate = DateTime.Now;
                    comment.ModerationRequestCount = comment.ModerationRequestCount-1;

                    // Update the comment entity
                    _commentService.UpdateComment(comment);

                    // Create a success notification
                    SuccessNotification("The comment remains active.");

                    // Send message to comment author and the comment flagger
                    _messageQueueService.CommentMessage(comment, MessageType.CommentRemovalRejected, queue.ModerationQueue.CreatedBy, "", form.UserMessage);
                }

                // Close the moderation queue item
                var queueUpdate = _moderationQueueService.GetById(id);
                queueUpdate.StatusType = ModerationStatusType.Closed;
                _moderationQueueService.UpdateModerationQueue(queueUpdate);

                return RedirectToRoute("Admin_default", new { Controller = "moderation", Action = "index" });
            }
            catch (Exception ex)
            {
                ErrorNotification(ex.ToString());
            }

            return View(model);
        }