|
||
|
API examples for newer versions Please visit the latest API Examples documentation to view API examples for newer versions of Kentico. |
The following example creates an attendee.
private bool CreateAttendee() { TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);
// Get event document TreeNode eventNode = tree.SelectSingleNode(CMSContext.CurrentSiteName, "/MyNewDocument/MyNewEvent", null, true);
if (eventNode != null) { // Create new attendee object EventAttendeeInfo newAttendee = new EventAttendeeInfo();
// Set the properties newAttendee.AttendeeEmail = "MyNewAttendee@localhost.local"; newAttendee.AttendeeEventNodeID = eventNode.NodeID; newAttendee.AttendeeFirstName = "My firstname"; newAttendee.AttendeeLastName = "My lastname";
// Save the attendee EventAttendeeInfoProvider.SetEventAttendeeInfo(newAttendee);
return true; }
return false; } |
The following example gets and updates an attendee.
private bool GetAndUpdateAttendee() { TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);
// Get event document TreeNode eventNode = tree.SelectSingleNode(CMSContext.CurrentSiteName, "/MyNewDocument/MyNewEvent", null, true);
if (eventNode != null) { // Get the attendee EventAttendeeInfo updateAttendee = EventAttendeeInfoProvider.GetEventAttendeeInfo(eventNode.NodeID, "MyNewAttendee@localhost.local"); if (updateAttendee != null) { // Update the properties updateAttendee.AttendeeEmail = updateAttendee.AttendeeEmail.ToLower();
// Save the changes EventAttendeeInfoProvider.SetEventAttendeeInfo(updateAttendee);
return true; } }
return false; } |
The following example gets and bulk updates attendees.
private bool GetAndBulkUpdateAttendees() { TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);
// Get event document TreeNode eventNode = tree.SelectSingleNode(CMSContext.CurrentSiteName, "/MyNewDocument/MyNewEvent", null, true);
if (eventNode != null) { // Prepare the parameters string where = "AttendeeEmail LIKE N'MyNewAttendee%'";
// Get the data DataSet attendees = EventAttendeeInfoProvider.GetEventAttendees(eventNode.NodeID, where, null, null, 0);
if (!DataHelper.DataSourceIsEmpty(attendees)) { // Loop through the individual items foreach (DataRow attendeeDr in attendees.Tables[0].Rows) { // Create object from DataRow EventAttendeeInfo modifyAttendee = new EventAttendeeInfo(attendeeDr);
// Update the properties modifyAttendee.AttendeeEmail = modifyAttendee.AttendeeEmail.ToUpper();
// Save the changes EventAttendeeInfoProvider.SetEventAttendeeInfo(modifyAttendee); }
return true; } }
return false; } |
The following example deletes an attendee.
private bool DeleteAttendee() { TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);
// Get event document TreeNode eventNode = tree.SelectSingleNode(CMSContext.CurrentSiteName, "/MyNewDocument/MyNewEvent", null, true);
if (eventNode != null) { // Get the attendee EventAttendeeInfo deleteAttendee = EventAttendeeInfoProvider.GetEventAttendeeInfo(eventNode.NodeID, "MyNewAttendee@localhost.local");
// Delete the attendee EventAttendeeInfoProvider.DeleteEventAttendeeInfo(deleteAttendee);
return (deleteAttendee != null); }
return false; } |