EventAttendeeInfoProvider.GetEventAttendeesCount Kentico 9 example

Chris Isom asked on June 12, 2016 07:46

I am working on a site that has been upgraded to version 9.01 and the API example on the site that shows the changes is not working. EventAttendeeInfoProvider.GetEventAttendeesCount() is not supported.

http://devnet.kentico.com/documentation/api-changes/kentico-9/9639

Any help would be greatly appreciated. The method is below.

/// <summary>
/// Displays registration section depending on situation
/// </summary>
protected void DisplayRegistration()
{
    //External Link, so simply display the link
    if (mEventExternalLink.Trim() != "")
    {
        lblError.Text = "<br/>Click <a href='" + mEventExternalLink + "'>here</a> to Register for this event.";
        lblError.Visible = true;
        mErrorOccurs = true;
    }
    else
    {
        DateTime now = DateTime.Now;
        // Display registration form if opened
        if ((mOpenFrom == DataHelper.DATETIME_NOT_SELECTED || mOpenFrom < now) && (mOpenTo == DataHelper.DATETIME_NOT_SELECTED || now <= mOpenTo) && (now <= mEventDate))
        {
            int actualCount = EventAttendeeInfoProvider.GetEventAttendeesCount(EventNode.OriginalNodeID);
            // Display registration form if mCapacity is not full
            if (actualCount == 0 || mCapacity == 0 || actualCount < mCapacity || mAllowRegistrationOverCapacity)
            {
                // User Logged in and CAN Register
                lblError.Text += "<br/><a href='" + RegisterPageURL + "?EventNodeID=" + EventNode.NodeID.ToString() + "'><img src='/img/button_register_now.gif' border='0' /></a>";
                lblError.Visible = true;
            }
            else
            {
                // All Seats Taken (FULL)
                lblError.Text = this.FullCapacityText;
                lblError.Visible = true;
                mErrorOccurs = true;
            }
        }
        else
        {
            // Event in the past
            lblError.Text = this.NotOpenedText;
            lblError.Visible = true;
            mErrorOccurs = true;
        }
    }
}

Thanks, Chirs

Correct Answer

Chris Isom answered on June 12, 2016 19:37

From Kentico:

Hello Chris,

Thank you for contacting us! It looks like there might be an error on that API Changes page.. sorry about that! In Kentico 9 you can use the following to get the number of event attendees:

EventAttendeeInfoProvider.GetEventAttendees(nodeID).Result.Tables[0].Rows.Count

I'll add this to the DevNet post as well, just in case other people run into this issue. Let me know if you have any other questions!

Eric Dugre Support Engineer

0 votesVote for this answer Unmark Correct answer

   Please, sign in to be able to submit a new answer.