Database Reference
In-Depth Information
_booking2 = new Booking
{
Customer = "Dolly Parton",
Paid = true,
BookingDate = DateTime.Parse("3/10/2010")
};
_agent1.Bookings.Add(_booking1);
_agent1.Bookings.Add(_booking2);
}
private async Task AddAgentAsync()
{
// call generic update method in Web API service to add agent and bookings
_response = await _client.PostAsync("api/travelagent/update/",
_agent1, new JsonMediaTypeFormatter());
if (_response.IsSuccessStatusCode)
{
// capture newly created travel agent from service, which will include
// database-generated Ids for each entity
_agent1 = await _response.Content.ReadAsAsync<TravelAgent>();
_booking1 = _agent1.Bookings.FirstOrDefault(x => x.Customer == "Karen Stevens");
_booking2 = _agent1.Bookings.FirstOrDefault(x => x.Customer == "Dolly Parton");
Console.WriteLine("Successfully created Travel Agent {0} and {1} Booking(s)",
_agent1.Name, _agent1.Bookings.Count);
}
else
Console.WriteLine("{0} ({1})", (int) _response.StatusCode, _response.ReasonPhrase);
}
private void CreateSecondAgent()
{
// add new agent and booking
_agent2 = new TravelAgent {Name = "Perry Como"};
_booking3 = new Booking
{
Customer = "Loretta Lynn",
Paid = true,
BookingDate = DateTime.Parse("3/15/2010")
};
_agent2.Bookings.Add(_booking3);
}
private async Task AddSecondAgentAsync()
{
// call generic update method in Web API service to add agent and booking
_response = await _client.PostAsync("api/travelagent/update/",
_agent2, new JsonMediaTypeFormatter());
Search WWH ::




Custom Search