/// <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 = "Giving Amount"; string[] selectionValues = selection.Split( '|' ); if ( selectionValues.Length >= 4 ) { ComparisonType comparisonType = selectionValues[0].ConvertToEnum<ComparisonType>( ComparisonType.GreaterThanOrEqualTo ); decimal amount = selectionValues[1].AsDecimalOrNull() ?? 0.00M; string accountNames = string.Empty; if ( selectionValues.Length >= 5 ) { var accountGuids = selectionValues[4].Split( ',' ).Select( a => a.AsGuid() ).ToList(); accountNames = new FinancialAccountService( new RockContext() ).GetByGuids( accountGuids ).Select( a => a.Name ).ToList().AsDelimited( "," ); } bool combineGiving = false; if ( selectionValues.Length >= 6 ) { combineGiving = selectionValues[5].AsBooleanOrNull() ?? false; } SlidingDateRangePicker fakeSlidingDateRangePicker = new SlidingDateRangePicker(); if ( selectionValues.Length >= 7 ) { // convert comma delimited to pipe fakeSlidingDateRangePicker.DelimitedValues = selectionValues[6].Replace( ',', '|' ); } else { // if converting from a previous version of the selection var lowerValue = selectionValues[2].AsDateTime(); var upperValue = selectionValues[3].AsDateTime(); fakeSlidingDateRangePicker.SlidingDateRangeMode = SlidingDateRangePicker.SlidingDateRangeType.DateRange; fakeSlidingDateRangePicker.SetDateRangeModeValue( new DateRange( lowerValue, upperValue ) ); } result = string.Format( "{4}Giving amount total {0} {1} {2}. Date Range: {3}", comparisonType.ConvertToString().ToLower(), amount.ToString( "C" ), !string.IsNullOrWhiteSpace( accountNames ) ? " to accounts:" + accountNames : string.Empty, SlidingDateRangePicker.FormatDelimitedValues( fakeSlidingDateRangePicker.DelimitedValues ), combineGiving ? "Combined " : string.Empty); } 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 = "First Contribution Date"; string[] selectionValues = selection.Split( '|' ); if ( selectionValues.Length >= 3 ) { SlidingDateRangePicker fakeSlidingDateRangePicker = new SlidingDateRangePicker(); if ( selectionValues.Length >= 4 ) { // convert comma delimited to pipe fakeSlidingDateRangePicker.DelimitedValues = selectionValues[3].Replace( ',', '|' ); } else { // if converting from a previous version of the selection var lowerValue = selectionValues[0].AsDateTime(); var upperValue = selectionValues[1].AsDateTime(); fakeSlidingDateRangePicker.SlidingDateRangeMode = SlidingDateRangePicker.SlidingDateRangeType.DateRange; fakeSlidingDateRangePicker.SetDateRangeModeValue( new DateRange( lowerValue, upperValue ) ); } string accountNames = string.Empty; var accountGuids = selectionValues[2].Split( ',' ).Select( a => a.AsGuid() ).ToList(); accountNames = new FinancialAccountService( new RockContext() ).GetByGuids( accountGuids ).Select( a => a.Name ).ToList().AsDelimited( "," ); result = string.Format( "First contribution date{0}. Date Range: {1}", !string.IsNullOrWhiteSpace( accountNames ) ? " to accounts:" + accountNames : string.Empty, SlidingDateRangePicker.FormatDelimitedValues( fakeSlidingDateRangePicker.DelimitedValues ) ) ; } return result; }