Database Reference
In-Depth Information
if (_response.IsSuccessStatusCode)
{
_bush = await _response.Content.ReadAsAsync<Customer>();
// set tracking state to 'Remove' to generate a SQL Delete statement
_bush.TrackingState = TrackingState.Remove;
// must also remove bush's mobile number -- must delete child before removing parent
foreach (var phoneType in _bush.Phones)
{
// set tracking state to 'Remove' to generate a SQL Delete statement
phoneType.TrackingState = TrackingState.Remove;
}
// construct call to remove Bush from underlying database table
_response = await _client.PostAsync("api/customer/updatecustomer/", _bush,
new JsonMediaTypeFormatter());
if (_response.IsSuccessStatusCode)
{
Console.WriteLine("Removed {0} from database", _bush.Name);
foreach (var phoneType in _bush.Phones)
{
Console.WriteLine("Remove {0} from data store", phoneType.PhoneType);
}
}
else
Console.WriteLine("{0} ({1})", (int) _response.StatusCode, _response.ReasonPhrase);
}
else
{
Console.WriteLine("{0} ({1})", (int) _response.StatusCode, _response.ReasonPhrase);
}
}
private async Task FetchCustomersAsync()
{
// finally, return remaining customers from underlying data store
_response = await _client.GetAsync("api/customer/");
if (_response.IsSuccessStatusCode)
{
var customers = await _response.Content.ReadAsAsync<IEnumerable<Customer>>();
foreach (var customer in customers)
{
Console.WriteLine("Customer {0} has {1} Phone Numbers(s)",
customer.Name, customer.Phones.Count());
Search WWH ::




Custom Search