Exemplo n.º 1
0
        /// <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 DataViewsPicker;
            string result = null;

            var selectedValues = new List <int>();

            if (picker != null)
            {
                foreach (System.Web.UI.WebControls.ListItem li in picker.Items)
                {
                    if (li.Selected)
                    {
                        selectedValues.Add(li.Value.AsInteger());
                    }
                }

                var guids = new List <Guid>();
                using (var rockContext = new RockContext())
                {
                    var dataViews = new DataViewService(rockContext).Queryable().AsNoTracking().Where(a => selectedValues.Contains(a.Id));

                    if (dataViews.Any())
                    {
                        guids = dataViews.Select(a => a.Guid).ToList();
                    }
                }

                result = string.Join(",", guids);
            }

            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns the field's current value(s)
        /// </summary>
        /// <param name="parentControl">The parent control.</param>
        /// <param name="value">Information about the value</param>
        /// <param name="configurationValues">The configuration values.</param>
        /// <param name="condensed">Flag indicating if the value should be condensed (i.e. for use in a grid column)</param>
        /// <returns></returns>
        public override string FormatValue(Control parentControl, string value, Dictionary <string, ConfigurationValue> configurationValues, bool condensed)
        {
            string formattedValue = string.Empty;

            if (!string.IsNullOrWhiteSpace(value))
            {
                var guids     = value.SplitDelimitedValues();
                var dataviews = new DataViewService(new RockContext()).Queryable().Where(a => guids.Contains(a.Guid.ToString()));
                if (dataviews.Any())
                {
                    formattedValue = string.Join(", ", (from dataview in dataviews select dataview.Name).ToArray());
                }
            }

            return(base.FormatValue(parentControl, formattedValue, null, condensed));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Formats the filter value value.
        /// </summary>
        /// <param name="configurationValues">The configuration values.</param>
        /// <param name="value">The value.</param>
        /// <returns></returns>
        public override string FormatFilterValueValue(Dictionary <string, ConfigurationValue> configurationValues, string value)
        {
            string formattedValue = string.Empty;

            if (!string.IsNullOrWhiteSpace(value))
            {
                using (var rockContext = new RockContext())
                {
                    var guids     = value.SplitDelimitedValues();
                    var dataviews = new DataViewService(rockContext).Queryable().AsNoTracking().Where(a => guids.Contains(a.Guid.ToString()));
                    if (dataviews.Any())
                    {
                        formattedValue = string.Join("' AND '", (from dataview in dataviews select dataview.Name).ToArray());
                    }
                }
            }

            return(AddQuotes(formattedValue));
        }