private void PopulateGroups(Dictionary <string, string> userPreferences = null)
        {
            string groupTypeTemplateGuid = this.GetAttributeValue("GroupTypeTemplate");

            if (!String.IsNullOrEmpty(groupTypeTemplateGuid))
            {
                var groupType = new GroupTypeService(new RockContext()).Get(groupTypeTemplateGuid.AsGuid());
                var groups    = new ChildCheckInGroupGenerator().Get(new List <GroupType> {
                    groupType
                });
                ddlGroups.Items.Clear();
                //Find groups with schedules which folks can attend
                foreach (var group in groups.Where(g => g.GroupLocations.Any(l => l.Schedules.Count > 0)))
                {
                    var listItem = new ListItem();
                    listItem.Text  = group.Name;
                    listItem.Value = group.Id.ToString();
                    ddlGroups.Items.Add(listItem);
                }
                if (ddlGroups.Items.Count < 1)
                {
                    DisplayBox("No groups found for the selected Attendance Type", NotificationBoxType.Warning);
                }
            }
        }
Пример #2
0
        private void PopulateGroups()
        {
            int checkInTemplateId = DefinedValueCache.Get(Rock.SystemGuid.DefinedValue.GROUPTYPE_PURPOSE_CHECKIN_TEMPLATE).Id;
            var checkInTemplates  = new GroupTypeService(new RockContext()).Queryable().AsNoTracking().Where(g => g.GroupTypePurposeValueId == checkInTemplateId);
            var groups            = new ChildCheckInGroupGenerator().Get(checkInTemplates).AsEnumerable();

            if (GetAttributeValue("StrictCampusFilter").AsBoolean())
            {
                groups = groups.Where(g => g.CampusId == _campusId);
            }
            else
            {
                groups = groups.Where(g => g.CampusId == null || g.CampusId == _campusId);
            }
            ddlGroups.Items.Clear();
            var enumeratedGroups = groups as IList <Group> ?? groups.ToList();

            foreach (var group in enumeratedGroups)
            {
                var listItem = new ListItem();
                listItem.Text  = group.Name;
                listItem.Value = group.Id.ToString();
                ddlGroups.Items.Add(listItem);
            }
            if (ddlGroups.Items.Count < 1)
            {
                nbWarning.Heading = "No checkin groups found.";
            }
            else
            {
                if (_groupId.HasValue && enumeratedGroups.Any(g => g.Id == _groupId.Value))
                {
                    ddlGroups.SelectedValue = _groupId.ToString();
                }
            }
        }