Database Reference
In-Depth Information
private static async Task Run()
{
var program = new Program();
program.ServiceSetup();
// do not proceed until clean-up completes
await program.CleanupAsync();
program.CreateFirstCustomer();
// do not proceed until customer is added
await program.AddCustomerAsync();
program.CreateSecondCustomer();
// do not proceed until customer is added
await program.AddSecondCustomerAsync();
// do not proceed until customer is removed
await program.RemoveFirstCustomerAsync();
// do not proceed until customers are fetched
await program.FetchCustomersAsync();
}
private void ServiceSetup()
{
// set up infrastructure for Web API call
_client = new HttpClient {BaseAddress = new Uri(" http://localhost:62799/ " )};
// add Accept Header to request Web API content negotiation to return resource in JSON format
_client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue
("application/json"));
}
private async Task CleanupAsync()
{
// call the cleanup method from the service
_response = await _client.DeleteAsync("api/customer/cleanup/");
}
private void CreateFirstCustomer()
{
// create customer #1 and two phone numbers
_bush = new Customer
{
Name = "George Bush",
Company = "Ex President",
// set tracking state to 'Add' to generate a SQL Insert statement
TrackingState = TrackingState.Add,
};
_whiteHousePhone = new Phone
{
Number = "212 222-2222",
PhoneType = "White House Red Phone",
// set tracking state to 'Add' to generate a SQL Insert statement
TrackingState = TrackingState.Add,
};
Search WWH ::




Custom Search