public ActionResult CopyDmp(int id) { var project = ProjectRepository.Get(id); if (project == null) { return(View("ProjectNotFound")); } if (!this.CurrentUser.IsPrincipalInvestigatorFor(project)) { return(View("NoProjectAccessRight")); } if (project.DataManagementPlan != null && project.ProvisioningStatus != ProvisioningStatus.NotStarted) { return(RedirectToAction("New", "Dmp", new { id })); } var availableProjects = GetAvailableProjects(id); if (availableProjects.Count != 0) { var copyViewModel = new CopyDataManagementPlanProjectViewModel { DestinationProjectId = id, AvailableProjects = availableProjects }; return(View(copyViewModel)); } return(RedirectToAction("New", "Dmp", new { id })); }
public ActionResult CopyDmp(CopyDataManagementPlanProjectViewModel model) { if (!ModelState.IsValid) { model.AvailableProjects = GetAvailableProjects(model.DestinationProjectId); return(View("CopyDmp", model)); } var formParams = ControllerContext.HttpContext.Request.Form; var dmpList = formParams["ProjectList"]; var proceedBtn = formParams["saveAndProceed"]; if (proceedBtn != null) { if (model.CopyFromExistingDmp != null && (bool)model.CopyFromExistingDmp) { int sourceProjectId; if (int.TryParse(dmpList, out sourceProjectId)) { var sourceProject = ProjectRepository.Get(sourceProjectId); var destProject = ProjectRepository.Get(model.DestinationProjectId); destProject.DataManagementPlan = sourceProject.DataManagementPlan.Clone(); destProject.DataManagementPlan.Id = 0; ProjectRepository.Save(destProject); return(RedirectToAction("Edit", "Dmp", new { id = destProject.DataManagementPlan.Id, step = 1 })); } } return(RedirectToAction("New", "Dmp", new { id = model.DestinationProjectId, step = 1 })); } return(RedirectToAction("Project", "Project", new { id = model.DestinationProjectId })); }