Skip to content

Instantly share code, notes, and snippets.

@ksummerlin
Last active August 29, 2015 14:03
Show Gist options
  • Save ksummerlin/9fd63651647ff697641e to your computer and use it in GitHub Desktop.
Save ksummerlin/9fd63651647ff697641e to your computer and use it in GitHub Desktop.
[AcceptVerbs("PATCH")]
public HttpResponseMessage PatchOrder(int id, Order updatedOrder)
{
using (DBOrderEntities objContext = new DBOrderEntities()) {
var order = objContext.Orders.SingleOrDefault(o => o.ID == id);
if (order == null)
{
throw new HttpResponseException(HttpStatusCode.NotFound);
}
//write code to update the given proerties here.
objContext.SaveChanges();
}
return Request.CreateResponse(HttpStatusCode.NoContent);
}
@ksummerlin
Copy link
Author

The first version shows how to handle the PATCH request using the AcceptVerbsAttribute. But there is still a lot of potential code to write to determine exactly which properties of the updatedOrder were sent with the request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment