public HttpResponseMessage Put(Workflow workflow) { if (repository.EditWorkflow(workflow)) { DataSourceResult result = new DataSourceResult { Data = new[] { workflow }, Total = 1 }; HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, result); response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = workflow.WorkflowID })); return response; } else return Request.CreateResponse(HttpStatusCode.BadRequest, ModelState); }
public HttpResponseMessage Post(Workflow workflow) { // set default value for user id if (workflow.OwnerID == 0) workflow.OwnerID = 1; if (workflow.WorkerID == 0) workflow.WorkerID = 1; if (repository.AddWorkflow(workflow)) { DataSourceResult result = new DataSourceResult { Data = new[] { workflow }, Total = 1 }; HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, result); response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = workflow.WorkflowID })); return response; } else return Request.CreateResponse(HttpStatusCode.BadRequest, ModelState); }