public void PutState(PD_State item, int id, int sid, int stid)
        {
             var _p = _db.PD_Processes.Find(id);
             if (User.Identity.Name.Equals(_p.LockedBy))
             {
                 var state = _db.PD_States.Find(id, sid, stid);

                 if (state != null)
                 {
                     if (item.Name != null)
                     {
                         state.Name = item.Name;
                     }
                     state.PositionTop = item.PositionTop;
                     state.PositionLeft = item.PositionLeft;
                     _db.SaveChanges();
                 }
                 else
                 {
                     throw new HttpResponseException(HttpStatusCode.NotFound);
                 }
             }
        }
        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;
             }
        }