Database Reference
In-Depth Information
private static void Main()
{
Task t = Run();
t.Wait();
Console.WriteLine("\nPress <enter> to continue...");
Console.ReadLine();
}
private static async Task Run()
{
var program = new Program();
program.ServiceSetup();
// do not proceed until clean-up is completed
await program.CleanupAsync();
program.CreateFirstAgent();
// do not proceed until agent is created
await program.AddAgentAsync();
program.CreateSecondAgent();
// do not proceed until agent is created
await program.AddSecondAgentAsync();
program.ModifyAgent();
// do not proceed until agent is updated
await program.UpdateAgentAsync();
// do not proceed until agents are fetched
await program.FetchAgentsAsync();
}
private void ServiceSetup()
{
// set up infrastructure for Web API call
_client = new HttpClient {BaseAddress = new Uri(" http://localhost:6687/ " )};
// 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 cleanup method in service
_response = await _client.DeleteAsync("api/travelagent/cleanup/");
}
private void CreateFirstAgent()
{
// create new Travel Agent and booking
_agent1 = new TravelAgent {Name = "John Tate"};
_booking1 = new Booking
{
Customer = "Karen Stevens",
Paid = false,
BookingDate = DateTime.Parse("2/2/2010")
};
Search WWH ::




Custom Search