Database Reference
In-Depth Information
_obamaMobilePhone = new Phone
{
Number = "212 444-4444",
PhoneType = "Obama Mobile Phone",
// set tracking state to 'Add' to generate a SQL Insert statement
TrackingState = TrackingState.Add,
};
// set tracking state to 'Modifed' to generate a SQL Update statement
_whiteHousePhone.TrackingState = TrackingState.Update;
_obama.Phones.Add(_obamaMobilePhone);
_obama.Phones.Add(_whiteHousePhone);
}
private async Task AddSecondCustomerAsync()
{
// construct call to invoke UpdateCustomer action method in Web API service
_response = await _client.PostAsync("api/customer/updatecustomer/",
_obama, new JsonMediaTypeFormatter());
if (_response.IsSuccessStatusCode)
{
// capture newly created customer entity from service, which will include
// database-generated Ids for all entities
_obama = await _response.Content.ReadAsAsync<Customer>();
_whiteHousePhone = _bush.Phones.FirstOrDefault(x => x.CustomerId == _obama.CustomerId);
_bushMobilePhone = _bush.Phones.FirstOrDefault(x => x.CustomerId == _obama.CustomerId);
Console.WriteLine("Successfully created Customer {0} and {1} Phone Numbers(s)",
_obama.Name, _obama.Phones.Count);
foreach (var phoneType in _obama.Phones)
{
Console.WriteLine("Added Phone Type: {0}", phoneType.PhoneType);
}
}
else
Console.WriteLine("{0} ({1})", (int) _response.StatusCode, _response.ReasonPhrase);
}
private async Task RemoveFirstCustomerAsync()
{
// remove George Bush from underlying data store.
// first, fetch George Bush entity, demonstrating a call to the
// get action method on the service while passing a parameter
var query = "api/customer/" + _bush.CustomerId;
_response = _client.GetAsync(query).Result;
Search WWH ::




Custom Search