Last active
August 29, 2015 14:03
-
-
Save ksummerlin/9fd63651647ff697641e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.