Skip to content

Instantly share code, notes, and snippets.

@jwillman
Created October 10, 2012 12:31
Show Gist options
  • Save jwillman/3865326 to your computer and use it in GitHub Desktop.
Save jwillman/3865326 to your computer and use it in GitHub Desktop.
// PUT api/Todo/5
public HttpResponseMessage PutTodo(int id, Todo todo)
{
if (ModelState.IsValid && id == todo.TodoId)
{
db.Entry(todo).State = EntityState.Modified;
try
{
db.SaveChanges();
}
catch (DbUpdateConcurrencyException)
{
return Request.CreateResponse(HttpStatusCode.NotFound);
}
return Request.CreateResponse(HttpStatusCode.OK);
}
else
{
return Request.CreateResponse(HttpStatusCode.BadRequest);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment