public void CopyChangedValues_UnRelatedType_Throws_Argument() { // Arrange Delta <Base> delta = new Delta <Base>(typeof(Derived)); AnotherDerived unrelatedEntity = new AnotherDerived(); // Act & Assert Assert.ThrowsArgument( () => delta.CopyChangedValues(unrelatedEntity), "original", "Cannot use Delta of type 'System.Web.OData.DeltaTest+Derived' on an entity of type 'System.Web.OData.DeltaTest+AnotherDerived'."); }
public IHttpActionResult Patch([FromODataUri]int key, Delta<Supplier> changedSupplier) { if (!ModelState.IsValid) { return BadRequest(ModelState); } var originalSupplier = _suppliers.SingleOrDefault(p => p.Id == key); if (originalSupplier == null) { return NotFound(); } changedSupplier.CopyChangedValues(originalSupplier); return Ok(); }
public IHttpActionResult Patch([FromODataUri]int key, Delta<Product> changedProduct) { if (!ModelState.IsValid) { return BadRequest(ModelState); } var originalProduct = _products.SingleOrDefault(p => p.Id == key); if (originalProduct == null) { return NotFound(); } changedProduct.CopyChangedValues(originalProduct); return StatusCode(HttpStatusCode.OK); }