in FMLab/Odata4ConsoleApplication/Program.cs [19:86]
static void Main(string[] args)
{
//the following BaseUri needs to be updated to your org
string dynamicsBaseUri = "https://usnconeboxax1aos.cloud.onebox.dynamics.com/";
string ODataServiceEndpoint = dynamicsBaseUri + "data";
Uri dynODataURI = new Uri(ODataServiceEndpoint, UriKind.Absolute);
//Creates a DataServiceContext class which encapsulates operations that are supported by the OData endpoint
context = new Resources(dynODataURI);
//Authenticate the user
AuthenticationHelper.PerformAuthentication(context,dynamicsBaseUri);
Console.WriteLine("-------------------------------------------------------------------");
Console.WriteLine("Query all the customers in Fleet Management. Enter to start ...");
Console.WriteLine("-------------------------------------------------------------------");
Console.ReadLine();
GetAllCustomers();
Console.WriteLine();
Console.WriteLine("-------------------------------------");
Console.WriteLine("Create a new customer. Enter to start");
Console.WriteLine("-------------------------------------");
Console.ReadLine();
FleetCustomer newCustomer = CreateCustomer();
Console.WriteLine();
Console.WriteLine("--------------------------------------------------------------------");
Console.WriteLine("Create a new reservation for the customer. Enter to start ...");
Console.WriteLine("--------------------------------------------------------------------");
Console.ReadLine();
FleetRental newRental = CreateReservation(newCustomer);
Console.WriteLine();
Console.WriteLine("--------------------------------------------------------------------");
Console.WriteLine("Call action on the reservation ...");
Console.WriteLine("--------------------------------------------------------------------");
Console.ReadLine();
UriBuilder buildUri = new UriBuilder(ODataServiceEndpoint);
buildUri.Path = String.Format("data/FleetRentals('{0}')/Microsoft.Dynamics.DataEntities.ReturnRental", newRental.RentalId);
//following code invokes the action by sending an HTTPPost request for the buildUri
var returnValue = context.Execute<string>(new Uri(buildUri.ToString()), "POST", true);
Console.ForegroundColor = ConsoleColor.Cyan;
Console.WriteLine("Invoked ReturnRental action, response is: \n" + returnValue.Single());
Console.ForegroundColor = ConsoleColor.White;
Console.BackgroundColor = ConsoleColor.Black;
Console.WriteLine();
Console.WriteLine("***************************************************");
Console.WriteLine("* *");
Console.WriteLine("You have successfully completed, \t\t\n 1. Creating a new customer \t\t\t\n 2. Creating a new reservation for that customer. \n " +
"Please refer back to Hands on Lab documentation to continue \n Press Enter to close this application \t");
Console.WriteLine("* *");
Console.WriteLine("***************************************************");
Console.ReadLine();
}