Skip to content

Instantly share code, notes, and snippets.

@andyyou
Created June 5, 2013 03:04
Show Gist options
  • Save andyyou/5711337 to your computer and use it in GitHub Desktop.
Save andyyou/5711337 to your computer and use it in GitHub Desktop.
public HttpResponseMessage PutGame(int id, Game game)
{
if (ModelState.IsValid && id == game.Id)
{
var g = db.Games.Find(id);
g.InjectFrom(game);
g.ModifyOn = DateTime.Now;
game.InsertOn = DateTime.Now;
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