public IHttpActionResult PostSimpleOpenCustomer([FromBody] SimpleOpenCustomer customer) { // Verify there is a string dynamic property object countryValue; customer.CustomerProperties.TryGetValue("Country", out countryValue); Assert.NotNull(countryValue); Assert.Equal(typeof(String), countryValue.GetType()); Assert.Equal("My Dynamic Country", countryValue); // Verify there is a Guid dynamic property object tokenValue; customer.CustomerProperties.TryGetValue("Token", out tokenValue); Assert.NotNull(tokenValue); Assert.Equal(typeof(Guid), tokenValue.GetType()); Assert.Equal(new Guid("2c1f450a-a2a7-4fe1-a25d-4d9332fc0694"), tokenValue); // Verify there is an dynamic collection property object value; customer.CustomerProperties.TryGetValue("DoubleList", out value); Assert.NotNull(value); List <double> doubleValues = Assert.IsType <List <double> >(value); Assert.Equal(new[] { 5.5, 4.4, 3.3 }, doubleValues); return(Ok()); }
public IHttpActionResult Put(int key, SimpleOpenCustomer changedCustomer) { Assert.Equal(99, changedCustomer.CustomerId); Assert.Equal("ChangedName", changedCustomer.Name); Assert.Null(changedCustomer.Address); Assert.Null(changedCustomer.Website); Assert.Equal(1, changedCustomer.CustomerProperties.Count); return(Updated(changedCustomer)); // Updated(customer); }
public IHttpActionResult GetAddress(int key) { IList <SimpleOpenCustomer> customers = CreateCustomers(); SimpleOpenCustomer customer = customers.FirstOrDefault(c => c.CustomerId == key); if (customer == null) { return(NotFound()); } return(Ok(customer.Address)); }
public IHttpActionResult Patch(int key, Delta <SimpleOpenCustomer> patch) { IList <SimpleOpenCustomer> customers = CreateCustomers(); SimpleOpenCustomer customer = customers.FirstOrDefault(c => c.CustomerId == key); if (customer == null) { return(NotFound()); } patch.Patch(customer); // As normal, return Updated(customer) for *PATCH*. // But, Here returns the *Ok* to test the payload return(Ok(customer)); }
public IHttpActionResult Get(int key) { IList <SimpleOpenCustomer> customers = CreateCustomers(); SimpleOpenCustomer customer = customers.FirstOrDefault(c => c.CustomerId == key); if (customer == null) { return(NotFound()); } if (customer.CustomerProperties == null) { customer.CustomerProperties = new Dictionary <string, object>(); customer.CustomerProperties.Add("Token", new Guid("2C1F450A-A2A7-4FE1-A25D-4D9332FC0694")); IList <int> lists = new List <int> { 1, 2, 3, 4, 5, 6, 7 }; customer.CustomerProperties.Add("MyList", lists); } return(Ok(customer)); }
public IHttpActionResult Put(int key, SimpleOpenCustomer changedCustomer) { Assert.Equal(99, changedCustomer.CustomerId); Assert.Equal("ChangedName", changedCustomer.Name); Assert.Null(changedCustomer.Address); Assert.Null(changedCustomer.Website); Assert.Equal(1, changedCustomer.CustomerProperties.Count); return Updated(changedCustomer); // Updated(customer); }