in FMLab/ODataConsoleApplication/Program.cs [143:178]
private static Customer CreateCustomer()
{
Console.WriteLine("Enter First Name, and then press Enter");
string firstName = Console.ReadLine();
Console.WriteLine("Enter Last Name, and then press Enter ");
string lastName = Console.ReadLine();
//Create the Customer object with the first and last names provided by the user
Customer newCustomer = new Customer()
{
FirstName = firstName,
LastName = lastName,
CellPhone = "0123456789",
Email = "test@contoso.com"
};
//Add the new customer object to the DataServiceContext object
context.AddToCustomers(newCustomer);
//Save the DataServiceContext object and an internally a POST call is made to the OData Customer entity.
//Record is created in Rainier Database
OperationResponse response = context.SaveChanges().First();
Console.ForegroundColor = ConsoleColor.Cyan;
if (response.Error == null)
{
Console.WriteLine("New customer created: ");
//Display the URI of the new customer
Console.WriteLine(response.Headers["Location"]);
}
Console.ForegroundColor = ConsoleColor.White;
return newCustomer ;
}