public ActionResult Moderation(int id, bool type, ProjectModerationModel form)
        {
            if (!_permissionService.Authorize(PermissionProvider.ManageProjects))
                return AccessDeniedView();

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

            // Get the action in preparation for updating
            var project = queue.Project;
            if (project == null)
                return RedirectToAction("index");

            // Prepare the presenation model
            var model = queue.ToModel();

            try
            {
                var queueUpdate = _moderationQueueService.GetById(id);
                project.ModeratorNotes = form.Project.ModerationNotes;

                if (type)
                {
                    // Update the project properties
                    project.LastModeratorApprovalBy = _workContext.CurrentUser.Id;
                    project.LastModeratorApprovalDate = DateTime.Now;
                    project.Status = ProjectStatus.Banned;

                    // Commit the changes
                    _projectService.UpdateProject(project);
                    SuccessNotification("The moderation request has been resolved, the action has been banned.");

                    // Queue the messages
                    _messageQueueService.ProjectMessage(project, MessageType.ProjectModerationApproved, form.ModerationQueue.Notes, form.VolunteersMessage, true, queue.ModerationQueue.CreatedBy);

                    // Remove outstanding project content complaints if any are in the queue as the action has been deleted.
                    _moderationQueueService.RemoveAllProjectModerationEntriesByProjectId(project.Id, model.ModerationQueue.Id);
                }
                else
                {
                    // Commit the changes
                    _projectService.UpdateProject(project);
                    SuccessNotification("The moderation request has been resolved, the action remains active.");

                    // Queue the messages
                    _messageQueueService.ProjectMessage(project, MessageType.ProjectModerationRejected, "", "", false, queueUpdate.CreatedBy);
                }

                // Mark the moderation request as resolved
                queueUpdate.StatusType = ModerationStatusType.Closed;
                _moderationQueueService.UpdateModerationQueue(queueUpdate);

                return RedirectToRoute("Admin_default", new { Controller = "moderation", Action = "index" });
            }
            catch (Exception ex)
            {
                ErrorNotification(ex.ToString());
                ErrorNotification("An error occurred saving the action details, please try again.");
            }

            PrepareModerationBreadcrumbs();
            return View(model);
        }
        public static ProjectModerationModel ToModel(this ProjectModeration entity)
        {
            if (entity == null)
                return null;

            var model = new ProjectModerationModel
            {
                Id = entity.Id,
                Project = entity.Project.ToModel(),
                ComplaintId = entity.ComplaintId,
                ComplaintType = entity.ComplaintType,
                ModerationQueue = entity.ModerationQueue.ToModel(),
                Reason = entity.Reason
            };

            return model;
        }