/// <summary> /// Reads new values entered by the user for the field /// </summary> /// <param name="control">Parent control that controls were added to in the CreateEditControl() method</param> /// <param name="configurationValues">The configuration values.</param> /// <returns></returns> public override string GetEditValue(Control control, Dictionary <string, ConfigurationValue> configurationValues) { var picker = control as RegistrationTemplatePicker; if (picker == null) { return(null); } string result = null; var ids = picker.SelectedValuesAsInt().ToList(); using (var rockContext = new RockContext()) { var registrationTemplates = new RegistrationTemplateService(rockContext).GetByIds(ids).ToList(); if (registrationTemplates.Any()) { result = registrationTemplates.Select(s => s.Guid.ToString()).ToList().AsDelimited(","); } } return(result); }
/// <summary> /// Formats the selection. /// </summary> /// <param name="entityType">Type of the entity.</param> /// <param name="selection">The selection.</param> /// <returns></returns> public override string FormatSelection(Type entityType, string selection) { string result = "Registrant"; string[] selectionValues = selection.Split('|'); if (selectionValues.Length >= 1) { var rockContext = new RockContext(); var registrationTemplateGuids = selectionValues[0].Split(',').AsGuidList(); var registrationTemplates = new RegistrationTemplateService(rockContext).GetByGuids(registrationTemplateGuids); SlidingDateRangePicker fakeSlidingDateRangePicker = null; bool includeInactiveRegistrationInstances = false; if (selectionValues.Length >= 2) { includeInactiveRegistrationInstances = selectionValues[1].AsBooleanOrNull() ?? false; if (selectionValues.Length >= 3) { fakeSlidingDateRangePicker = new SlidingDateRangePicker(); // convert comma delimited to pipe fakeSlidingDateRangePicker.DelimitedValues = selectionValues[2].Replace(',', '|'); } } if (registrationTemplates != null) { result = string.Format(registrationTemplates.Count() > 0 ? "In Registration Templates: {0}" : "In a Registration", registrationTemplates.Select(a => a.Name).ToList().AsDelimited(", ", " or ")); if (includeInactiveRegistrationInstances) { result += ", including inactive registration instances"; } if (fakeSlidingDateRangePicker != null) { result += string.Format(", registered in Date Range: {0}", SlidingDateRangePicker.FormatDelimitedValues(fakeSlidingDateRangePicker.DelimitedValues)); } } } return(result); }
/// <summary> /// Formats the selection. /// </summary> /// <param name="entityType">Type of the entity.</param> /// <param name="selection">The selection.</param> /// <returns></returns> public override string FormatSelection( Type entityType, string selection ) { string result = "Registrant"; string[] selectionValues = selection.Split( '|' ); if ( selectionValues.Length >= 1 ) { var rockContext = new RockContext(); var registrationTemplateGuids = selectionValues[0].Split( ',' ).AsGuidList(); var registrationTemplates = new RegistrationTemplateService( rockContext ).GetByGuids( registrationTemplateGuids ); SlidingDateRangePicker fakeSlidingDateRangePicker = null; bool includeInactiveRegistrationInstances = false; if ( selectionValues.Length >= 2 ) { includeInactiveRegistrationInstances = selectionValues[1].AsBooleanOrNull() ?? false; if ( selectionValues.Length >= 3 ) { fakeSlidingDateRangePicker = new SlidingDateRangePicker(); // convert comma delimited to pipe fakeSlidingDateRangePicker.DelimitedValues = selectionValues[2].Replace( ',', '|' ); } } if ( registrationTemplates != null ) { result = string.Format( registrationTemplates.Count() > 0 ? "In Registration Templates: {0}" : "In a Registration", registrationTemplates.Select( a => a.Name ).ToList().AsDelimited( ", ", " or " ) ); if ( includeInactiveRegistrationInstances ) { result += ", including inactive registration instances"; } if ( fakeSlidingDateRangePicker != null ) { result += string.Format( ", registered in Date Range: {0}", SlidingDateRangePicker.FormatDelimitedValues( fakeSlidingDateRangePicker.DelimitedValues ) ); } } } return result; }