Ejemplo n.º 1
0
        /// <summary>
        /// Gets the selected GroupMember(s) as a comma-delimited list of GroupMember.Guid
        /// </summary>
        /// <param name="control">Parent control that controls were added to in the CreateEditControl() method</param>
        /// <param name="configurationValues"></param>
        /// <returns></returns>
        public override string GetEditValue(Control control, Dictionary <string, ConfigurationValue> configurationValues)
        {
            var groupMemberIdList = new List <int>();

            if (control != null && control is ListControl)
            {
                groupMemberIdList.AddRange((( ListControl )control).Items.Cast <ListItem>()
                                           .Where(i => i.Selected)
                                           .Select(i => i.Value).AsIntegerList());
            }

            var guids = new List <Guid>();

            if (groupMemberIdList.Any())
            {
                using (var rockContext = new RockContext())
                {
                    var groupMemberService = new GroupMemberService(rockContext);
                    guids = groupMemberService.GetByIds(groupMemberIdList).Select(a => a.Guid).ToList();
                }
            }

            return(guids.AsDelimited(","));
        }