예제 #1
0
            /// <summary>
            /// Format the data for persistence
            /// </summary>
            /// <param name="editorValue"></param>
            /// <param name="currentValue"></param>
            /// <returns></returns>
            public override object ConvertEditorToDb(Core.Models.Editors.ContentPropertyData editorValue, object currentValue)
            {
                if (editorValue.Value == null)
                {
                    return(null);
                }

                var parsed = MacroTagParser.FormatRichTextContentForPersistence(editorValue.Value.ToString());

                return(parsed);
            }
        /// <summary>
        /// When multiple values are selected a json array will be posted back so we need to format for storage in
        /// the database which is a comma separated string value
        /// </summary>
        /// <param name="editorValue"></param>
        /// <param name="currentValue"></param>
        /// <returns></returns>
        public override object FromEditor(Core.Models.Editors.ContentPropertyData editorValue, object currentValue)
        {
            var json = editorValue.Value as JArray;

            if (json == null)
            {
                return(null);
            }

            var values = json.Select(item => item.Value <string>()).ToArray();

            return(JsonConvert.SerializeObject(values));
        }
        /// <summary>
        /// When multiple values are selected a json array will be posted back so we need to format for storage in
        /// the database which is a comma separated string value
        /// </summary>
        /// <param name="editorValue"></param>
        /// <param name="currentValue"></param>
        /// <returns></returns>
        public override object FromEditor(Core.Models.Editors.ContentPropertyData editorValue, object currentValue)
        {
            var json = editorValue.Value as JArray;

            if (json == null)
            {
                return(null);
            }

            var values = json.Select(item => item.Value <string>()).ToList();

            //change to delimited
            return(string.Join(",", values));
        }