/// <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 MetricCategoryPicker; string result = null; if (picker != null) { var ids = picker.SelectedValuesAsInt(); var metricCategories = new MetricCategoryService(new RockContext()).Queryable().Where(a => ids.Contains(a.Id)); if (metricCategories.Any()) { var guidPairList = metricCategories.Select(a => new { MetricGuid = a.Metric.Guid, CategoryGuid = a.Category.Guid }).ToList(); result = guidPairList.Select(s => string.Format("{0}|{1}", s.MetricGuid, s.CategoryGuid)).ToList().AsDelimited(","); } } return(result); }
/// <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 MetricCategoryPicker; string result = null; if ( picker != null ) { var ids = picker.SelectedValuesAsInt(); var metricCategories = new MetricCategoryService( new RockContext() ).Queryable().Where( a => ids.Contains( a.Id ) ); if ( metricCategories.Any() ) { var guidPairList = metricCategories.Select( a => new { MetricGuid = a.Metric.Guid, CategoryGuid = a.Category.Guid } ).ToList(); result = guidPairList.Select( s => string.Format( "{0}|{1}", s.MetricGuid, s.CategoryGuid ) ).ToList().AsDelimited( "," ); } } return result; }