public ActionResult AddRefinementTo (int processid, int subjectid, string parameters, string name) { PD_RefinementState state = new PD_RefinementState(); state.PD_Process_Id = processid; state.Name = name; state.PD_Subject_Id = subjectid; state.PositionLeft = 100; state.PositionTop = 100; state.ReadableParameters = new PersistableStringCollection(); List<string> refparams = parameters.Split('|').ToList<string>(); foreach (string s in refparams) { if (s.Length > 0) { state.ReadableParameters.Add(s); } } state.Type = PD_StateTypes.RefinementState; _db.PD_States.Add(state); _db.SaveChanges(); return RedirectToAction("ViewSubject", new { processid = processid, subjectid = subjectid, edit = 1 }); }
public HttpResponseMessage PostState(PD_State item, int id, int sid) { var _p = _db.PD_Processes.Find(id); if (User.Identity.Name.Equals(_p.LockedBy)) { var subject = _db.PD_Subjects.Find(id, sid); PD_State newState = null; if (item.Type == PD_StateTypes.FunctionState) { newState = new PD_FunctionState() { Name = "Function State", EndState = false }; } if (item.Type == PD_StateTypes.SendState) { newState = new PD_SendState() { Name = "Send State", EndState = false }; } if (item.Type == PD_StateTypes.ReceiveState) { newState = new PD_ReceiveState() { Name = "Receive State", EndState = false }; } if (item.Type == PD_StateTypes.RefinementState) { newState = new PD_RefinementState() { Name = "Refinement State", EndState = false }; } newState.Id = IdHelper.getStateId(_db, id,sid); newState.PositionLeft = item.PositionLeft; newState.PositionTop = item.PositionTop; newState.StartState = false; if (subject.States.Count == 0) { newState.StartState = true; } subject.States.Add(newState); _db.SaveChanges(); var response = Request.CreateResponse<PD_StateDTO>(HttpStatusCode.Created, new PD_StateDTO { Id = newState.Id, Name = newState.Name, PositionLeft = newState.PositionLeft, PositionTop = newState.PositionTop, Type = newState.Type }); string uri = Url.Content("Designer" + id + "/Subjects/" + sid + "/States/" + newState.Id); response.Headers.Location = new Uri(uri); return response; } else { return null; } }