コード例 #1
0
ファイル: EBApi.cs プロジェクト: KingdomFirst/RockAssemblies
        public OrganizationEventsResponse GetOrganizationEvents(bool RSVP = false)
        {
            var evnts  = GetOrganizationEvents();
            var retVar = new OrganizationEventsResponse
            {
                Pagination = evnts.Pagination,
                Events     = new List <Event>()
            };

            if (evnts.Events != null)
            {
                foreach (var evnt in evnts.Events)
                {
                    var cq   = GetEventCannedQuestionsById(evnt.Id);
                    var test = cq.Questions.FirstOrDefault(q => q.Respondent.Equals("attendee", StringComparison.CurrentCultureIgnoreCase));
                    if ((test == null && RSVP) || (test != null && !RSVP))
                    {
                        retVar.Events.Add(evnt);
                    }
                }
            }
            else
            {
                retVar.Events = evnts.Events;
            }

            return(retVar);
        }
コード例 #2
0
        private void loadEvents()
        {
            var parentGroupGuid  = GetAttributeValue("NewGroupParent").AsGuidOrNull();
            var groupTypeGuid    = GetAttributeValue("NewGroupType").AsGuidOrNull();
            var newEventStatuses = GetAttributeValue("NewEventStatuses").SplitDelimitedValues(",").ToList();

            ddlEventbriteEvents.Items.Clear();
            if (parentGroupGuid.HasValue && groupTypeGuid.HasValue)
            {
                var eb = rocks.kfs.Eventbrite.Eventbrite.Api(_accessToken, Settings.GetOrganizationId().ToLong(0));
                var organizationEvents = eb.GetOrganizationEvents(GetAttributeValue("NewEventStatuses"));
                if (organizationEvents != null && organizationEvents.Pagination != null && organizationEvents.Pagination.Has_More_Items)
                {
                    var looper = new OrganizationEventsResponse();
                    for (int i = 2; i <= organizationEvents.Pagination.PageCount; i++)
                    {
                        looper = eb.GetOrganizationEvents(i, GetAttributeValue("NewEventStatuses"));
                        organizationEvents.Events.AddRange(looper.Events);
                    }
                }
                if (organizationEvents != null && organizationEvents.Events != null)
                {
                    foreach (var evnt in organizationEvents.Events.FindAll(e => newEventStatuses.Contains(e.Status)))
                    {
                        if (!_groups.Select(g => g.EventbriteEventId).ToList().Contains(evnt.Id))
                        {
                            ddlEventbriteEvents.Items.Add(new ListItem(string.Format("{0} - {1} ({2})", evnt.Name.Text.ToString(), evnt.Start.Local, evnt.Status), evnt.Id.ToString()));
                        }
                    }
                }
                ddlEventbriteEvents.Visible  = true;
                lbCreateNewRockGroup.Visible = true;
                nbLinkNew.Visible            = false;
            }
            else
            {
                ddlEventbriteEvents.Visible  = false;
                lbCreateNewRockGroup.Visible = false;
                nbLinkNew.Text = "Set the 'New Group Parent' and 'New Group Type' settings if you wish to use this feature.";
                nbLinkNew.NotificationBoxType = NotificationBoxType.Info;
                nbLinkNew.Visible             = true;
            }
            if (ddlEventbriteEvents.Items.Count == 0 && !nbLinkNew.Visible)
            {
                ddlEventbriteEvents.Visible = false;
                nbLinkNew.Text = "There are currently no events available to link.";
                nbLinkNew.NotificationBoxType = NotificationBoxType.Warning;
                nbLinkNew.Dismissable         = false;
                nbLinkNew.Visible             = true;
                lbCreateNewRockGroup.Visible  = false;
            }
        }
コード例 #3
0
        /// <summary>
        /// Creates the control(s) necessary for prompting user for a new value
        /// </summary>
        /// <param name="configurationValues">The configuration values.</param>
        /// <param name="id"></param>
        /// <returns>
        /// The control
        /// </returns>
        public override Control EditControl(Dictionary <string, ConfigurationValue> configurationValues, string id)
        {
            var parentControl = new Panel();
            var editControl   = new RockDropDownList {
                ID = id
            };

            editControl.Items.Add(new ListItem());
            var eb = new EBApi(Settings.GetAccessToken(), Settings.GetOrganizationId().ToLong(0));

            var organizationEvents = eb.GetOrganizationEvents("all", 500);

            if (organizationEvents.Pagination.Has_More_Items)
            {
                var looper = new OrganizationEventsResponse();
                for (int i = 2; i <= organizationEvents.Pagination.PageCount; i++)
                {
                    looper = eb.GetOrganizationEvents(i, "all", 500);
                    organizationEvents.Events.AddRange(looper.Events);
                }
            }

            if (organizationEvents != null && organizationEvents.Events != null)
            {
                foreach (var template in organizationEvents.Events)
                {
                    editControl.Items.Add(new ListItem(string.Format("{0} - {1} ({2})", template.Name.Text.ToString(), template.Start.Local, template.Status), template.Id.ToString()));
                }
                editControl.Attributes["data-syncdate"] = "";
                parentControl.Controls.Add(editControl);

                return(parentControl);
            }

            return(null);
        }