public ActionResult PublishProject_P1_Version(PublishProjectP1ViewModel vmodel) { var project = _db.WS_Projects.Find(vmodel.Id); int modelid = _db.WS_ModelVersions.Find(vmodel.Id, vmodel.SelectedVersion).PD_ProcessId; PublishProjectP2ValidateViewModel model = new PublishProjectP2ValidateViewModel() { ProjectId = project.Id, ProjectName = project.Name, ValidationErrors = new List <ValidationError>(), Version = vmodel.SelectedVersion }; SbpmModelHelper helper = new SbpmModelHelper(); //validate model model.ValidationErrors = helper.validateModel(modelid); if (model.ValidationErrors.Count == 0) { model.Success = true; } else { model.Success = false; } //translate model if (model.Success) { model.SubjectsCreated = helper.translateToXaml(model.ProjectId, modelid); project.CurrentVersion = vmodel.SelectedVersion; } _db.SaveChanges(); return(View("PublishProject_P2_Validation", model)); }
public ActionResult NewVersion(int WS_ProjectId) { var project = _db.WS_Projects.Find(WS_ProjectId); int maxversion = project.ModelVersions.Max(result => result.Version); int modelid = _db.WS_ModelVersions.First(result => result.WS_ProjectId == WS_ProjectId & result.Version == maxversion).PD_ProcessId; SbpmModelHelper helper = new SbpmModelHelper(); int NewModelId = helper.copyModel(modelid); if (NewModelId != -1) { _db.WS_ModelVersions.Add(new WS_ModelVersion() { PD_ProcessId = NewModelId, Version = maxversion + 1, WS_ProjectId = WS_ProjectId }); _db.SaveChanges(); } return(RedirectToAction("Index", new { id = WS_ProjectId })); }