XWeb Event Registration Csharp Code Sample
Overview
This code sample contains code fragments for:
- Instantiate a Shopping Cart Object (CentralizedOrderEntryType)
- Instantiate a Registrant Object (EventsRegistrantType)
- Add Fees to the Registrant via a FeeCollection
- Add the Registrant to the Cart
Code
These are just code fragments. Production code will have more error handling, etc.
// for this sample code// we have various properties in a Settings file// in real-life production code you'd get these values from the applicationvar props = MySite.Properties.Settings.Default; // instantiate web referencenetForumXML NFxWeb = new netForumXML(); NFxWeb.Authenticate(props.username, props.password); // Create new Cart for CustomerCentralizedOrderEntryType cart = NFxWeb.WEBCentralizedShoppingCartGetNew(props.cst_key); // Event that show online// In real-life app you'd need to determine which Event Key the person is trying to register for:XmlNode oNodeEvents = NFxWeb.WEBCentralizedShoppingCartGetEventList(); // Create new EventsRegistrantType for customer, for a particular Event Key:EventsRegistrantType reg = NFxWeb.WEBCentralizedShoppingCartEventRegistrantGetNew(props.cst_key, props.evt_key); // registrant types - somehow your application would need to iterate through these and// allow registrant to choose oneXmlNode oNodeRegType = NFxWeb.WEBCentralizedShoppingCartGetEventRegistrantTypeListByEvent(props.evt_key); // Set the registrant type propertyreg.Registrant.reg_rgt_key = "bba65476-d899-41d1-9ea4-de2a8ef8673b"; // full event // event fees - in real-life app you'd need to determine which Event and Session fees the user will chooseXmlNode oNode = NFxWeb.WEBCentralizedShoppingCartGetEventFees(reg, cart); // This is just a list of Fees for main event and sessions// In real-life the application would determine what these are by prompting the userList<Guid> feeGuids = new List<Guid>();feeGuids.Add(new Guid("1e31642d-c9fd-4566-bf80-5fb6cfeb92c1"));feeGuids.Add(new Guid("ccd29edb-e1e5-4810-8b8d-1304bd91f824"));feeGuids.Add(new Guid("de030daa-9350-44ad-aeda-49e381a13bf9"));feeGuids.Add(new Guid("2a38dd09-b16b-4816-b978-1e9a5f5d9e17"));feeGuids.Add(new Guid("d36faea4-4d32-4f37-a849-d6238346692e"));feeGuids.Add(new Guid("4ffe4960-da94-448d-b6b9-ecf32dcf21e8"));feeGuids.Add(new Guid("5f92d87f-52a8-4e3e-aada-84600c5195a1")); // Fees CollectionFee[] fees = new Fee[feeGuids.Count]; // Add each of the Fees above into the fees collection:for(int i = 0; i < feeGuids.Count; i++){ Fee eventFee = new Fee(); eventFee.prc_key = feeGuids[i]; eventFee.action = FeeAction.Add; eventFee.qty = 1; fees[i] = eventFee;} // Provide the fees collection to the Registrantreg = NFxWeb.WEBCentralizedShoppingCartEventRegistrantSetLineItems(reg, fees); // Add the Registrant to the Cartcart = NFxWeb.WEBCentralizedShoppingCartAddEventRegistrant(cart, reg);