// POST api/WorkFlowRecord public HttpResponseMessage PostWorkFlowRecord(WorkFlowRecord workflowrecord) { if (ModelState.IsValid) { workflowrecord.InsertBy = loginUser.UserID; db.WorkFlowRecords.Add(workflowrecord); db.SaveChanges(); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, workflowrecord); response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = workflowrecord.WorkFlowRecordID })); return response; } else { return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } }
// PUT api/WorkFlowRecord/5 public HttpResponseMessage PutWorkFlowRecord(long id, WorkFlowRecord workflowrecord) { if (!ModelState.IsValid) { return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } if (id != workflowrecord.WorkFlowRecordID) { return Request.CreateResponse(HttpStatusCode.BadRequest); } workflowrecord.UpdateBy = loginUser.UserID; db.Entry(workflowrecord).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException ex) { return Request.CreateErrorResponse(HttpStatusCode.NotFound, ex); } return Request.CreateResponse(HttpStatusCode.OK); }