示例#1
0
 /// <summary>
 /// Creates the property value model.
 /// </summary>
 /// <param name="value">The value.</param>
 /// <param name="property">The property.</param>
 /// <returns>PropertyValueModel.</returns>
 public static PropertyValueModel CreatePropertyValueModel(PropertyValueBase value, Property property)
 {
     if (property.IsEnum && !string.IsNullOrEmpty(value.KeyValue))
     {
         return CreatePropertyValueModel(property.PropertyValues.First(p => p.PropertyValueId == value.KeyValue));
     }
     return CreatePropertyValueModel(value);
 }
示例#2
0
        /// <summary>
        /// Creates the property value model.
        /// </summary>
        /// <param name="value">The value.</param>
        /// <returns>PropertyValueModel.</returns>
        /// <exception cref="System.ArgumentNullException">value</exception>
        public static PropertyValueModel CreatePropertyValueModel(PropertyValueBase value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            var model = new PropertyValueModel();
            model.InjectFrom<CloneInjection>(value);
            return model;
        }
        private void RaiseValueEditInteractionRequest(PropertyValueBase originalItem)
        {
            var item = originalItem.DeepClone(_entityFactory as CatalogEntityFactory);

            if (RaisePropertyValueEditInteractionRequest(item, "Edit property value".Localize()))
            {
                // copy all values to original:
                OnUIThread(() => originalItem.InjectFrom <CloneInjection>(item));
                // fake assign for UI triggers to display correct values.
                originalItem.ValueType = item.ValueType;
            }
        }
        public PropertyValueEditViewModel(PropertyValueBase item)
        {
            InnerItem = item;

            var itemValueType = (PropertyValueType)InnerItem.ValueType;

            IsShortStringValue = itemValueType == PropertyValueType.ShortString;
            IsLongStringValue  = itemValueType == PropertyValueType.LongString;
            IsDecimalValue     = itemValueType == PropertyValueType.Decimal;
            IsIntegerValue     = itemValueType == PropertyValueType.Integer;
            IsBooleanValue     = itemValueType == PropertyValueType.Boolean;
            IsDateTimeValue    = itemValueType == PropertyValueType.DateTime;
        }
        // function almost duplicated in ItemViewModel
        private void UpdatePropertyValue(PropertyValueBase newValue)
        {
            //TODO update value according to ValueType
            var item = InnerItem.CategoryPropertyValues.FirstOrDefault(x => x.PropertyValueId == newValue.PropertyValueId);

            if (item == null)
            {
                item = (CategoryPropertyValue)EntityFactory.CreateEntityForType(typeof(CategoryPropertyValue));
                InnerItem.CategoryPropertyValues.Add(item);
            }
            item.InjectFrom(newValue);
            item.CategoryId = InnerItem.CategoryId;
        }
        private void RaiseValueDeleteInteractionRequest(PropertyValueBase item)
        {
            var confirmation = new ConditionalConfirmation
            {
                Content = string.Format("Are you sure you want to delete dictionary Property value '{0}'?".Localize(), item),
                Title   = "Delete confirmation".Localize(null, LocalizationScope.DefaultCategory)
            };

            CommonConfirmRequest.Raise(confirmation, (x) =>
            {
                if (x.Confirmed)
                {
                    InnerItem.PropertyValues.Remove((PropertyValue)item);
                }
            });
        }
        protected virtual void IndexItemCustomProperties(ref ResultDocument doc, Item item)
        {
            foreach (var val in item.ItemPropertyValues)
            {
                var key = val.Name;

                PropertyValueBase indexVal = val;

                var prop = _properties.FirstOrDefault(p => p.Name == val.Name && p.CatalogId == item.CatalogId);

                //Handle dictionary value
                if (prop != null && prop.IsEnum)
                {
                    var dictVal = prop.PropertyValues.FirstOrDefault(p => p.PropertyValueId == val.KeyValue);
                    if (dictVal != null)
                    {
                        indexVal = dictVal;
                    }
                    else
                    {
                        break;
                    }
                }

                var contentField = string.Format("__content{0}",
                                                 prop != null && (prop.IsLocaleDependant && !string.IsNullOrWhiteSpace(indexVal.Locale)) ? "_" + indexVal.Locale.ToLower() : string.Empty);

                switch ((PropertyValueType)indexVal.ValueType)
                {
                case PropertyValueType.LongString:
                    doc.Add(new DocumentField(contentField, ConvertToLowcase(indexVal.LongTextValue), new[] { IndexStore.YES, IndexType.ANALYZED, IndexDataType.StringCollection }));
                    break;

                case PropertyValueType.ShortString:
                    doc.Add(new DocumentField(contentField, ConvertToLowcase(indexVal.ShortTextValue), new[] { IndexStore.YES, IndexType.ANALYZED, IndexDataType.StringCollection }));
                    break;
                }


                if (doc.ContainsKey(key))
                {
                    continue;
                }


                switch ((PropertyValueType)indexVal.ValueType)
                {
                case PropertyValueType.Boolean:
                    doc.Add(new DocumentField(key, indexVal.BooleanValue, new[] { IndexStore.YES, IndexType.ANALYZED }));
                    break;

                case PropertyValueType.DateTime:
                    doc.Add(new DocumentField(key, indexVal.DateTimeValue, new[] { IndexStore.YES, IndexType.ANALYZED }));
                    break;

                case PropertyValueType.Decimal:
                    doc.Add(new DocumentField(key, indexVal.DecimalValue, new[] { IndexStore.YES, IndexType.ANALYZED }));
                    break;

                case PropertyValueType.Integer:
                    doc.Add(new DocumentField(key, indexVal.IntegerValue, new[] { IndexStore.YES, IndexType.ANALYZED }));
                    break;

                case PropertyValueType.LongString:
                    doc.Add(new DocumentField(key, ConvertToLowcase(indexVal.LongTextValue), new[] { IndexStore.YES, IndexType.ANALYZED }));
                    break;

                case PropertyValueType.ShortString:
                    doc.Add(new DocumentField(key, ConvertToLowcase(indexVal.ShortTextValue), new[] { IndexStore.YES, IndexType.ANALYZED }));
                    break;
                }
            }
        }
示例#8
0
        /// <summary>
        /// Creates the property model.
        /// </summary>
        /// <param name="priority">The priority.</param>
        /// <param name="property">The property.</param>
        /// <param name="value">The value.</param>
        /// <param name="item">The item.</param>
        /// <returns>PropertyModel.</returns>
        /// <exception cref="System.ArgumentNullException">property</exception>
        public static PropertyModel CreatePropertyModel(int priority, Property property, PropertyValueBase value, StorageEntity item)
        {
            if (property == null)
            {
                throw new ArgumentNullException("property");
            }

            var model = new PropertyModel { Priority = priority };
            model.InjectFrom<CloneInjection>(property);
            model.Values = new[] { CreatePropertyValueModel(value, property) };
            model.CatalogItem = item;
            return model;
        }
 public PropertyValueWithFieldNameEditViewModel(PropertyValueBase item)
     : base(item)
 {
     Priority = item.Priority;
 }