public ActionResult ReviewDataDeposit(int projectId)
 {
     var project = _projectRepository.Get(projectId);
     if (project == null)
     {
         return View("ProjectNotFound");
     }
     if (project.SourceProjectType != SourceProjectType.DEPOSIT)
     {
         return View("IncorrectProjectType");
     }
     if (project.DataDeposit == null)
     {
         return View("DataDepositNotFound");
     }
     if (!this.CurrentUser.IsPrincipalInvestigatorFor(project))
     {
         return View("NoProjectAccessRight");
     }
     if (project.ProvisioningStatus == ProvisioningStatus.Provisioned)
     {
         return View("DataDepositProvisioned");
     }
     var vm = new ConfirmDataDepositViewModel { ProjectId = project.Id, ProjectTitle = project.Title };
     return View("ReviewDataDeposit", vm);
 }
        public ActionResult ReviewDataDeposit(ConfirmDataDepositViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return View(model);
            }

            // Get project information
            var project = _projectRepository.Get(model.ProjectId);
            if (project == null)
            {
                return View("ProjectNotFound");
            }
            if (project.SourceProjectType != SourceProjectType.DEPOSIT)
            {
                return View("IncorrectProjectType");
            }
            if (project.DataDeposit == null)
            {
                return View("DataDepositNotFound");
            }
            if (!this.CurrentUser.IsPrincipalInvestigatorFor(project))
            {
                return View("NoProjectAccessRight");
            }
            if (project.ProvisioningStatus == ProvisioningStatus.Provisioned)
            {
                return View("DataDepositProvisioned");
            }

            // Start provisioning workflow
			// TODO: You can use the URDMS.Integration solution to handle provisioning in a robust manner or just alter the database directly as in the
			// commented code below and implement further actions from the web application.
			_bus.Send<SiteRequestCommand>(m =>
			{
				m.ProjectId = project.Id;
				m.ProjectTitle = project.Title;
				m.ProjectDescription = project.Description;
				m.UserRoles = CreateUserRolesDictionary(project);
			});

			//project.ProvisioningStatus = ProvisioningStatus.Pending;
			//_projectRepository.Save(project);

            if (!project.DataCollections.Any(dc => dc.IsFirstCollection))
            {
                var dataCollection = project.CreateInitialDataCollection();
                _dataCollectionRepository.Save(dataCollection);
            }

            return RedirectToAction("SubmittedDataDeposit", new { projectId = model.ProjectId });
        }