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 PublishProject_P1_Version(int projectId)
        {
            var project = _db.WS_Projects.Find(projectId);

            int latestVersion = project.ModelVersions.Max(result => result.Version);

            List<SelectListItem> versions = new List<SelectListItem>();
            foreach (var version in project.ModelVersions)
            {
                var nv = new SelectListItem() { Text = "" + version.Version, Value = "" + version.Version };
                if (version.Version == latestVersion)
                    nv.Selected = true;
                versions.Add(nv);
            }

            PublishProjectP1ViewModel model = new PublishProjectP1ViewModel() { Id = project.Id, SelectedVersion = latestVersion, ProjectName = project.Name, Versions = versions };

            return View(model);
        }