Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// PUT: api/Order
[HttpPut]
public async Task<IActionResult> PutOrder([FromBody] Order order)
{
// Apply changes to context
_context.ApplyChanges(order);
try
{
// Persist changes
await _context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
if (!_context.Orders.Any(o => o.OrderId == order.OrderId))
return NotFound();
throw;
}
// Populate reference properties
await _context.LoadRelatedEntitiesAsync(order);
// Reset tracking state to unchanged
_context.AcceptChanges(order);
// Return updated order
return Ok(order);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.