public async Task <IActionResult> PutOrder([FromBody] Order order) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } // 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 NoContent(); return(Ok(order)); }