Exemplo n.º 1
0
        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'.");
        }
Exemplo n.º 2
0
        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();
        }
Exemplo n.º 3
0
        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);
        }