public ActionResult Change(int id) { if (!_permissionService.Authorize(PermissionProvider.ManageProjects)) return AccessDeniedView(); // Get the queue item var queue = _moderationQueueService.GetProjectChangeRequestByModerationQueueId(id); if (queue == null || queue.Deleted) return RedirectToAction("index", "moderation"); // Get the action var project = queue.ChangeProject; if (project == null || project.Deleted) return RedirectToAction("index"); // Check we have a parent var parentProject = queue.ParentProject; if (parentProject == null || parentProject.Deleted) return RedirectToAction("index"); var model = new ProjectEditModel { Project = PrepareProjectModel(project), ParentProject = parentProject.ToModel(), }; model.Project.Volunteers = model.ParentProject.Volunteers; model.Project.ModerationNotes = model.ParentProject.ModerationNotes; PrepareModerationBreadcrumbs(); AddBreadcrumb("Action Content Change Request", null); return View(model); }
public ActionResult Reject(ProjectEditModel model) { if (!_permissionService.Authorize(PermissionProvider.ManageProjects)) return AccessDeniedView(); // Get the queue item var queue = _moderationQueueService.GetProjectChangeRequestByModerationQueueId(model.Id); if (queue == null || queue.Deleted) return RedirectToAction("index", "moderation"); // Get the action var project = queue.ChangeProject; if (project == null) return RedirectToAction("index"); // Store the parent var parentProject = queue.ParentProject; try { project.LastModifiedBy = _workContext.CurrentUser.Id; project.StatusId = (int)ProjectStatus.Deleted; project.ModeratorNotes = model.Project.ModerationNotes; _projectService.UpdateProject(project); SuccessNotification("The action change request has been rejected."); _messageQueueService.ProjectMessage(parentProject, MessageType.ProjectChangeRejected, model.AuthorMessage, model.VolunteersMessage, model.NotifyVolunteers); var queueUpdate = _moderationQueueService.GetById(model.Id); queueUpdate.StatusType = ModerationStatusType.Closed; _moderationQueueService.UpdateModerationQueue(queueUpdate); return RedirectToRoute("Admin_default", new { Controller = "moderation", Action = "index" }); } catch (Exception) { ErrorNotification("An error occurred hiding the action, please try again."); } var updateModel = new ProjectEditModel { Project = PrepareProjectModel(project), ParentProject = queue.ParentProject.ToModel(), Id = model.Id }; PrepareModerationBreadcrumbs(); AddBreadcrumb("Action Content Change Request", null); return View(updateModel); }
public ActionResult Change(ProjectEditModel model, FormCollection form) { if (!_permissionService.Authorize(PermissionProvider.ManageProjects)) return AccessDeniedView(); var queue = _moderationQueueService.GetProjectChangeRequestByModerationQueueId(model.Id); if (queue == null || queue.Deleted) return RedirectToAction("index", "moderation"); // get the action var project = queue.ChangeProject; if (project == null) return RedirectToAction("index"); // Store the parent var parentProject = queue.ParentProject; if (ModelState.IsValid) { try { // Update fields var selectedCategoryIds = form["SelectedCategories"] != null ? form["SelectedCategories"].Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList() : new List<string>(); var availableCategories = _categoryService.GetAllCategories(); parentProject.Categories.Clear(); foreach (var categoryId in selectedCategoryIds.Select(int.Parse)) parentProject.Categories.Add(availableCategories.First(x => x.Id == categoryId)); parentProject.LastModifiedBy = _workContext.CurrentUser.Id; parentProject.ChildFriendly = model.Project.ChildFriendly; parentProject.EmailAddress = model.Project.EmailAddress; parentProject.EmailDisclosureId = model.Project.EmailDisclosureId; parentProject.EndDate = model.Project.EndDate; parentProject.Equipment = model.Project.Equipment; parentProject.GettingThere = model.Project.GettingThere; parentProject.Name = model.Project.Name; parentProject.NumberOfVolunteers = model.Project.NumberOfVolunteers; parentProject.Objective = model.Project.Objective; parentProject.RecurrenceIntervalId = model.Project.RecurrenceIntervalId; parentProject.Recurrence = model.Project.Recurrence; parentProject.Skills = model.Project.Skills; parentProject.StartDate = model.Project.StartDate; parentProject.Telephone = model.Project.Telephone; parentProject.TelephoneDisclosureId = model.Project.TelephoneDisclosureId; parentProject.VolunteerBenefits = model.Project.VolunteerBenefits; parentProject.Website = model.Project.Website; parentProject.WebsiteDisclosureId = model.Project.WebsiteDisclosureId; parentProject.IsRecurring = model.Project.IsRecurring; parentProject.ModeratorNotes = model.Project.ModerationNotes; // Make sure we have the correct status for the date provided // This is important if a project date is changed after it's already started if (parentProject.Status == ProjectStatus.InProgress) { if (parentProject.StartDate > DateTime.Now) { parentProject.StatusId = (int) ProjectStatus.Open; } else if (parentProject.EndDate < DateTime.Now) { parentProject.StatusId = (int) ProjectStatus.Closed; } } else if (parentProject.Status == ProjectStatus.Closed && parentProject.StartDate > DateTime.Now) { parentProject.StatusId = (int)ProjectStatus.Open; } else if (parentProject.Status == ProjectStatus.Closed && parentProject.StartDate < DateTime.Now && parentProject.EndDate > DateTime.Now) { parentProject.StatusId = (int)ProjectStatus.InProgress; } else if (parentProject.Status == ProjectStatus.Open && parentProject.StartDate < DateTime.Now) { if (parentProject.EndDate > DateTime.Now) { parentProject.StatusId = (int)ProjectStatus.InProgress; } else { parentProject.StatusId = (int) ProjectStatus.Closed; } } // Commit the parent project changes _projectService.UpdateProject(parentProject); // Update change request record project.Status = ProjectStatus.Deleted; parentProject.LastModifiedBy = _workContext.CurrentUser.Id; _projectService.UpdateProject(project); SuccessNotification("The action has been updated."); _messageQueueService.ProjectMessage(parentProject, MessageType.ProjectChangeApproved, model.AuthorMessage, model.VolunteersMessage, model.NotifyVolunteers); var queueUpdate = _moderationQueueService.GetById(model.Id); 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."); } } var updateModel = new ProjectEditModel { Id = model.Id, ParentProject = parentProject.ToModel(), Project = PrepareProjectModel(project) }; PrepareModerationBreadcrumbs(); AddBreadcrumb("Action Content Change Request", null); return View(updateModel); }