public coreModel.Property GetById(string propertyId)
        {
            coreModel.Property retVal = null;
            using (var repository = _catalogRepositoryFactory())
            {
                var dbProperty = repository.GetPropertiesByIds(new string[] { propertyId }).FirstOrDefault();
                if (dbProperty != null)
                {
                    dataModel.Catalog  dbCatalog  = null;
                    dataModel.Category dbCategory = null;
                    dbCatalog = repository.GetPropertyCatalog(dbProperty.Id);
                    if (dbCatalog == null)
                    {
                        dbCategory = repository.GetPropertyCategory(dbProperty.Id);
                        dbCatalog  = repository.GetCatalogById(dbCategory.CatalogId) as dataModel.Catalog;
                    }

                    var catalog  = dbCatalog.ToCoreModel();
                    var category = dbCategory != null?dbCategory.ToCoreModel(catalog) : null;

                    retVal = dbProperty.ToCoreModel(catalog, category);
                }
            }
            return(retVal);
        }
Beispiel #2
0
        /// <summary>
        /// Converting to foundation type
        /// </summary>
        /// <param name="category">The category.</param>
        /// <returns></returns>
        public static dataModel.Category ToDataModel(this coreModel.Category category, PrimaryKeyResolvingMap pkMap)
        {
            var retVal = new dataModel.Category();

            pkMap.AddPair(category, retVal);
            retVal.InjectFrom(category);

            retVal.ParentCategoryId = category.ParentId;
            retVal.EndDate          = DateTime.UtcNow.AddYears(100);
            retVal.StartDate        = DateTime.UtcNow;
            retVal.IsActive         = category.IsActive ?? true;

            if (category.PropertyValues != null)
            {
                retVal.CategoryPropertyValues = new ObservableCollection <dataModel.PropertyValue>();
                retVal.CategoryPropertyValues.AddRange(category.PropertyValues.Select(x => x.ToDataModel(pkMap)));
            }

            if (category.Links != null)
            {
                retVal.OutgoingLinks = new ObservableCollection <dataModel.CategoryRelation>();
                retVal.OutgoingLinks.AddRange(category.Links.Select(x => x.ToDataModel(category)));
            }

            #region Images
            if (category.Images != null)
            {
                retVal.Images = new ObservableCollection <dataModel.Image>(category.Images.Select(x => x.ToDataModel(pkMap)));
            }
            #endregion

            return(retVal);
        }
Beispiel #3
0
        /// <summary>
        /// Converting to foundation type
        /// </summary>
        /// <param name="category">The category.</param>
        /// <returns></returns>
        public static dataModel.CategoryBase ToDataModel(this coreModel.Category category)
        {
            var retVal = new dataModel.Category();

            var id = retVal.Id;

            retVal.InjectFrom(category);
            if (category.Id == null)
            {
                retVal.Id = id;
            }
            retVal.ParentCategoryId = category.ParentId;
            retVal.EndDate          = DateTime.UtcNow.AddYears(100);
            retVal.StartDate        = DateTime.UtcNow;

            if (category.PropertyValues != null)
            {
                retVal.CategoryPropertyValues = new ObservableCollection <dataModel.CategoryPropertyValue>();
                retVal.CategoryPropertyValues.AddRange(category.PropertyValues.Select(x => x.ToDataModel <dataModel.CategoryPropertyValue>()).OfType <dataModel.CategoryPropertyValue>());
            }

            if (category.Links != null)
            {
                retVal.OutgoingLinks = new ObservableCollection <dataModel.CategoryRelation>();
                retVal.OutgoingLinks.AddRange(category.Links.Select(x => x.ToDataModel(category)));
            }

            return(retVal);
        }
Beispiel #4
0
        public dataModel.Property[] GetAllCategoryProperties(dataModel.Category category)
        {
            var retVal = new List <dataModel.Property>();

            if (category.PropertySet != null)
            {
                retVal.AddRange(category.PropertySet.PropertySetProperties.Select(x => x.Property));
            }
            if (category.ParentCategoryId != null)
            {
                var parentCategory = GetCategoryById(category.ParentCategoryId);
                if (parentCategory != null)
                {
                    retVal.AddRange(GetAllCategoryProperties(parentCategory));
                }
            }

            //Add catalog properties
            if (category.Catalog == null)
            {
                category.Catalog = GetCatalogById(category.CatalogId);
            }
            retVal.AddRange(GetCatalogProperties(category.Catalog));
            return(retVal.Distinct().ToArray());
        }
Beispiel #5
0
 private static Category CloneCategory(Category category)
 {
     return(new Category
     {
         Id = category.Id,
         ParentCategoryId = category.ParentCategoryId,
         CatalogId = category.CatalogId,
         Catalog = _catalogs.FirstOrDefault(c => c.Id == category.CatalogId),
     });
 }
Beispiel #6
0
        public dataModel.Category[] GetAllCategoryParents(dataModel.Category category)
        {
            var retVal = new List <dataModel.Category>();

            if (category.ParentCategoryId != null)
            {
                var parentCategory = Categories.FirstOrDefault(x => x.Id == category.ParentCategoryId);
                if (parentCategory != null)
                {
                    retVal.Add(parentCategory);
                    retVal.AddRange(GetAllCategoryParents(parentCategory));
                }
            }
            return(retVal.ToArray());
        }
Beispiel #7
0
        public dataModel.Category GetPropertyCategory(string propId)
        {
            dataModel.Category retVal = null;
            var propSet = PropertySets.FirstOrDefault(x => x.PropertySetProperties.Any(y => y.PropertyId == propId));

            if (propSet != null)
            {
                var categoryId = Categories.Where(x => x.PropertySetId == propSet.Id)
                                 .Select(x => x.Id).FirstOrDefault();
                if (categoryId != null)
                {
                    retVal = GetCategoryById(categoryId);
                }
            }
            return(retVal);
        }
Beispiel #8
0
        /// <summary>
        /// Patch changes
        /// </summary>
        /// <param name="source"></param>
        /// <param name="target"></param>
        public static void Patch(this coreModel.Category source, dataModel.Category target, PrimaryKeyResolvingMap pkMap)
        {
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }

            //TODO: temporary solution because partial update replaced not nullable properties in db entity
            if (source.IsActive != null)
            {
                target.IsActive = source.IsActive.Value;
            }
            //Handle three valuable states (null, empty and have value states) for case when need reset catalog or category
            if (source.CatalogId == String.Empty)
            {
                target.CatalogId = null;
            }
            if (source.ParentId == String.Empty)
            {
                target.ParentCategoryId = null;
            }


            var dbSource = source.ToDataModel(pkMap) as dataModel.Category;
            var dbTarget = target as dataModel.Category;

            if (dbSource != null && dbTarget != null)
            {
                var patchInjectionPolicy = new PatchInjection <dataModel.Category>(x => x.Code, x => x.Name, x => x.TaxType, x => x.CatalogId, x => x.ParentCategoryId);
                dbTarget.InjectFrom(patchInjectionPolicy, dbSource);

                if (!dbSource.CategoryPropertyValues.IsNullCollection())
                {
                    dbSource.CategoryPropertyValues.Patch(dbTarget.CategoryPropertyValues, (sourcePropValue, targetPropValue) => sourcePropValue.Patch(targetPropValue));
                }

                if (!dbSource.OutgoingLinks.IsNullCollection())
                {
                    dbSource.OutgoingLinks.Patch(dbTarget.OutgoingLinks, new LinkedCategoryComparer(), (sourceLink, targetLink) => sourceLink.Patch(targetLink));
                }

                if (!dbSource.Images.IsNullCollection())
                {
                    dbSource.Images.Patch(dbTarget.Images, (sourceImage, targetImage) => sourceImage.Patch(targetImage));
                }
            }
        }
        /// <summary>
        /// Converting to model type
        /// </summary>
        /// <param name="dbCategory">The database category base.</param>
        /// <param name="catalog">The catalog.</param>
        /// <param name="properties">The properties.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">catalog</exception>
        public static coreModel.Category ToCoreModel(this dataModel.Category dbCategory, coreModel.Catalog catalog,
                                                     coreModel.Property[] properties = null, dataModel.Category[] allParents = null)
        {
            if (catalog == null)
            {
                throw new ArgumentNullException("catalog");
            }

            var retVal = new coreModel.Category();

            retVal.InjectFrom(dbCategory);
            retVal.CatalogId = catalog.Id;
            retVal.Catalog   = catalog;
            retVal.ParentId  = dbCategory.ParentCategoryId;
            retVal.IsActive  = dbCategory.IsActive;


            retVal.PropertyValues = dbCategory.CategoryPropertyValues.Select(x => x.ToCoreModel(properties)).ToList();
            retVal.Virtual        = catalog.Virtual;
            retVal.Links          = dbCategory.OutgoingLinks.Select(x => x.ToCoreModel(retVal)).ToList();


            if (allParents != null)
            {
                retVal.Parents = allParents.Select(x => x.ToCoreModel(catalog)).ToArray();
            }

            //Try to inherit taxType from parent category
            if (retVal.TaxType == null && retVal.Parents != null)
            {
                retVal.TaxType = retVal.Parents.Select(x => x.TaxType).Where(x => x != null).FirstOrDefault();
            }

            #region Images
            if (dbCategory.Images != null)
            {
                retVal.Images = dbCategory.Images.OrderBy(x => x.SortOrder).Select(x => x.ToCoreModel()).ToList();
            }
            #endregion

            return(retVal);
        }
        private Category ConvertToCategory(External.CatalogModule.Web.CatalogModuleApi.Models.Category dto)
        {
            var dbCategory = new dataModel.Category()
            {
                Id        = dto.Id,
                CatalogId = dto.CatalogId,
            };

            var retVal = dbCategory.ToCoreModel(base.AllCachedCatalogs, base.AllCachedCategories.Concat(new[] { dbCategory }).ToArray());

            retVal.Parents        = new Category[] { };
            retVal.Links          = new List <CategoryLink>();
            retVal.PropertyValues = new List <PropertyValue>();
            retVal.InjectFrom(dto);

            if (!dto.Outlines.IsNullOrEmpty())
            {
                retVal.Outlines = dto.Outlines.Select(x => ConvertToOutline(x)).ToList();
            }
            return(retVal);
        }
Beispiel #11
0
        public void SetCategoryProperty(dataModel.Category category, dataModel.Property property)
        {
            if (category.PropertySet == null)
            {
                var propertySet = new dataModel.PropertySet
                {
                    Name       = category.Name + " property set",
                    TargetType = "Category"
                };
                Add(propertySet);
                category.PropertySetId = propertySet.Id;
            }

            var propertySetProperty = new dataModel.PropertySetProperty
            {
                PropertySetId = category.PropertySetId,
                PropertyId    = property.Id
            };

            Add(propertySetProperty);
        }
Beispiel #12
0
        /// <summary>
        /// Patch changes
        /// </summary>
        /// <param name="source"></param>
        /// <param name="target"></param>
        public static void Patch(this coreModel.Category source, dataModel.Category target, PrimaryKeyResolvingMap pkMap)
        {
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }

            //TODO: temporary solution because partial update replaced not nullable properties in db entity
            if (source.IsActive != null)
            {
                target.IsActive = source.IsActive.Value;
            }

            var dbSource = source.ToDataModel(pkMap) as dataModel.Category;
            var dbTarget = target as dataModel.Category;

            if (dbSource != null && dbTarget != null)
            {
                dbTarget.CatalogId        = string.IsNullOrEmpty(dbSource.CatalogId) ? null : dbSource.CatalogId;
                dbTarget.ParentCategoryId = string.IsNullOrEmpty(dbSource.ParentCategoryId) ? null : dbSource.ParentCategoryId;
                dbTarget.Code             = dbSource.Code;
                dbTarget.Name             = dbSource.Name;
                dbTarget.TaxType          = dbSource.TaxType;

                if (!dbSource.CategoryPropertyValues.IsNullCollection())
                {
                    dbSource.CategoryPropertyValues.Patch(dbTarget.CategoryPropertyValues, (sourcePropValue, targetPropValue) => sourcePropValue.Patch(targetPropValue));
                }

                if (!dbSource.OutgoingLinks.IsNullCollection())
                {
                    dbSource.OutgoingLinks.Patch(dbTarget.OutgoingLinks, new LinkedCategoryComparer(), (sourceLink, targetLink) => sourceLink.Patch(targetLink));
                }

                if (!dbSource.Images.IsNullCollection())
                {
                    dbSource.Images.Patch(dbTarget.Images, (sourceImage, targetImage) => sourceImage.Patch(targetImage));
                }
            }
        }
        /// <summary>
        /// Patch changes
        /// </summary>
        /// <param name="source"></param>
        /// <param name="target"></param>
        public static void Patch(this coreModel.Category source, dataModel.Category target)
        {
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }

            //TODO: temporary solution because partial update replaced not nullable properties in db entity
            if (source.IsActive != null)
            {
                target.IsActive = source.IsActive.Value;
            }

            var dbSource = source.ToDataModel() as dataModel.Category;
            var dbTarget = target as dataModel.Category;

            if (dbSource != null && dbTarget != null)
            {
                var patchInjectionPolicy = new PatchInjection <dataModel.Category>(x => x.Code, x => x.Name, x => x.TaxType);
                target.InjectFrom(patchInjectionPolicy, source);

                if (!dbSource.CategoryPropertyValues.IsNullCollection())
                {
                    dbSource.CategoryPropertyValues.Patch(dbTarget.CategoryPropertyValues, (sourcePropValue, targetPropValue) => sourcePropValue.Patch(targetPropValue));
                }

                if (!dbSource.OutgoingLinks.IsNullCollection())
                {
                    dbSource.OutgoingLinks.Patch(dbTarget.OutgoingLinks, new LinkedCategoryComparer(), (sourceLink, targetLink) => sourceLink.Patch(targetLink));
                }

                if (!dbSource.Images.IsNullCollection())
                {
                    dbSource.Images.Patch(dbTarget.Images, (sourceImage, targetImage) => sourceImage.Patch(targetImage));
                }
            }
        }
        /// <summary>
        /// Converting to foundation type
        /// </summary>
        /// <param name="category">The category.</param>
        /// <returns></returns>
        public static dataModel.Category ToDataModel(this coreModel.Category category)
        {
			var retVal = new dataModel.Category();

			var id = retVal.Id;
			retVal.InjectFrom(category);
			if(category.Id == null)
			{
				retVal.Id = id;
			}
			retVal.ParentCategoryId = category.ParentId;
			retVal.EndDate = DateTime.UtcNow.AddYears(100);
			retVal.StartDate = DateTime.UtcNow;
			retVal.IsActive = category.IsActive ?? true;
          
            if (category.PropertyValues != null)
            {
                retVal.CategoryPropertyValues = new ObservableCollection<dataModel.CategoryPropertyValue>();
                retVal.CategoryPropertyValues.AddRange(category.PropertyValues.Select(x => x.ToDataModel<dataModel.CategoryPropertyValue>()).OfType<dataModel.CategoryPropertyValue>());
            }

            if (category.Links != null)
            {
				retVal.OutgoingLinks = new ObservableCollection<dataModel.CategoryRelation>();
				retVal.OutgoingLinks.AddRange(category.Links.Select(x => x.ToDataModel(category)));
            }

			#region Images
			if (category.Images != null)
			{
				retVal.Images = new ObservableCollection<dataModel.Image>(category.Images.Select(x=>x.ToDataModel()));
			}
			#endregion

            return retVal;
        }
 private static Category CloneCategory(Category category)
 {
     return new Category
     {
         Id = category.Id,
         ParentCategoryId = category.ParentCategoryId,
         CatalogId = category.CatalogId,
         Catalog = _catalogs.FirstOrDefault(c => c.Id == category.CatalogId),
     };
 }
Beispiel #16
0
        public virtual Category ToModel(Category category)
        {
            if (category == null)
            {
                throw new ArgumentNullException(nameof(category));
            }

            category.Id = Id;
            category.CreatedBy = CreatedBy;
            category.CreatedDate = CreatedDate;
            category.ModifiedBy = ModifiedBy;
            category.ModifiedDate = ModifiedDate;
            category.OuterId = OuterId;

            category.Code = Code;
            category.Name = Name;
            category.Priority = Priority;
            category.TaxType = TaxType;

            category.CatalogId = CatalogId;

            category.ParentId = ParentCategoryId;
            category.IsActive = IsActive;

            category.Links = OutgoingLinks.Select(x => x.ToModel(new CategoryLink())).ToList();
            category.Images = Images.OrderBy(x => x.SortOrder).Select(x => x.ToModel(AbstractTypeFactory<Image>.TryCreateInstance())).ToList();
            // SeoInfos
            category.SeoInfos = SeoInfos.Select(x => x.ToModel(AbstractTypeFactory<SeoInfo>.TryCreateInstance())).ToList();
            category.Properties = Properties.Select(x => x.ToModel(AbstractTypeFactory<Property>.TryCreateInstance()))
                                           .OrderBy(x => x.Name)
                                           .ToList();
            foreach (var property in category.Properties)
            {
                property.IsReadOnly = property.Type != PropertyType.Category;
            }
            //transform property value into transient properties
            if (!CategoryPropertyValues.IsNullOrEmpty())
            {
                var propertyValues = CategoryPropertyValues.OrderBy(x => x.DictionaryItem?.SortOrder)
                                                       .ThenBy(x => x.Name)
                                                       .SelectMany(pv => pv.ToModel(AbstractTypeFactory<PropertyValue>.TryCreateInstance()).ToList());

                var transientInstanceProperties = propertyValues.GroupBy(pv => pv.PropertyName).Select(values =>
                {
                    var property = AbstractTypeFactory<Property>.TryCreateInstance();
                    property.Type = PropertyType.Category;
                    property.Name = values.Key;
                    property.ValueType = values.FirstOrDefault().ValueType;
                    property.Values = values.ToList();
                    foreach (var propValue in property.Values)
                    {
                        propValue.Property = property;
                    }
                    return property;
                }).OrderBy(x => x.Name).ToList();

                foreach (var transientInstanceProperty in transientInstanceProperties)
                {
                    var existSelfProperty = category.Properties.FirstOrDefault(x => x.IsSame(transientInstanceProperty, PropertyType.Category));
                    if (existSelfProperty == null)
                    {
                        category.Properties.Add(transientInstanceProperty);
                    }
                    else
                    {
                        //Just only copy values for existing self property
                        existSelfProperty.Values = transientInstanceProperty.Values;
                    }
                }
            }
            return category;
        }
        /// <summary>
        /// Converting to foundation type
        /// </summary>
        /// <param name="category">The category.</param>
        /// <returns></returns>
        public static dataModel.Category ToDataModel(this coreModel.Category category, PrimaryKeyResolvingMap pkMap)
        {
			var retVal = new dataModel.Category();
            pkMap.AddPair(category, retVal);
            retVal.InjectFrom(category);
	
			retVal.ParentCategoryId = category.ParentId;
			retVal.EndDate = DateTime.UtcNow.AddYears(100);
			retVal.StartDate = DateTime.UtcNow;
			retVal.IsActive = category.IsActive ?? true;
          
            if (category.PropertyValues != null)
            {
                retVal.CategoryPropertyValues = new ObservableCollection<dataModel.PropertyValue>();
                retVal.CategoryPropertyValues.AddRange(category.PropertyValues.Select(x => x.ToDataModel(pkMap)));
            }

            if (category.Links != null)
            {
				retVal.OutgoingLinks = new ObservableCollection<dataModel.CategoryRelation>();
				retVal.OutgoingLinks.AddRange(category.Links.Select(x => x.ToDataModel(category)));
            }

			#region Images
			if (category.Images != null)
			{
				retVal.Images = new ObservableCollection<dataModel.Image>(category.Images.Select(x=>x.ToDataModel(pkMap)));
			}
			#endregion

            return retVal;
        }
Beispiel #18
0
        public virtual CategoryEntity FromModel(Category category, PrimaryKeyResolvingMap pkMap)
        {
            if (category == null)
            {
                throw new ArgumentNullException(nameof(category));
            }

            pkMap.AddPair(category, this);

            Id = category.Id;
            CreatedBy = category.CreatedBy;
            CreatedDate = category.CreatedDate;
            ModifiedBy = category.ModifiedBy;
            ModifiedDate = category.ModifiedDate;
            OuterId = category.OuterId;

            Code = category.Code;
            Name = category.Name;
            Priority = category.Priority;
            TaxType = category.TaxType;
            CatalogId = category.CatalogId;

            ParentCategoryId = category.ParentId;
            EndDate = DateTime.UtcNow.AddYears(100);
            StartDate = DateTime.UtcNow;
            IsActive = category.IsActive ?? true;

            if (!category.Properties.IsNullOrEmpty())
            {
                var propValues = new List<PropertyValue>();
                foreach (var property in category.Properties.Where(x => x.Type == PropertyType.Category))
                {
                    if (property.Values != null)
                    {
                        //Do not use values from inherited properties and skip empty values
                        foreach (var propValue in property.Values.Where(x => !x.IsInherited && !x.IsEmpty))
                        {
                            //Need populate required fields
                            propValue.PropertyName = property.Name;
                            propValue.ValueType = property.ValueType;
                            propValues.Add(propValue);
                        }
                    }
                }
                if (!propValues.IsNullOrEmpty())
                {
                    CategoryPropertyValues = new ObservableCollection<PropertyValueEntity>(AbstractTypeFactory<PropertyValueEntity>.TryCreateInstance().FromModels(propValues, pkMap));
                }
            }

            if (category.Links != null)
            {
                OutgoingLinks = new ObservableCollection<CategoryRelationEntity>(category.Links.Select(x => AbstractTypeFactory<CategoryRelationEntity>.TryCreateInstance().FromModel(x)));
            }

            if (category.Images != null)
            {
                Images = new ObservableCollection<ImageEntity>(category.Images.Select(x => AbstractTypeFactory<ImageEntity>.TryCreateInstance().FromModel(x, pkMap)));
            }

            if (category.SeoInfos != null)
            {
                SeoInfos = new ObservableCollection<SeoInfoEntity>(category.SeoInfos.Select(x => AbstractTypeFactory<SeoInfoEntity>.TryCreateInstance().FromModel(x, pkMap)));
            }

            return this;
        }
Beispiel #19
0
        /// <summary>
        /// Converting to model type
        /// </summary>
        /// <param name="dbCategory">The database category base.</param>
        /// <param name="catalog">The catalog.</param>
        /// <param name="properties">The properties.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">catalog</exception>
        public static coreModel.Category ToCoreModel(this dataModel.Category dbCategory, bool convertProps = true)
        {
            var retVal = new coreModel.Category();

            retVal.InjectFrom(dbCategory);
            retVal.CatalogId = dbCategory.CatalogId;
            retVal.Catalog   = dbCategory.Catalog.ToCoreModel();
            retVal.ParentId  = dbCategory.ParentCategoryId;
            retVal.IsActive  = dbCategory.IsActive;

            retVal.Virtual = dbCategory.Catalog.Virtual;
            retVal.Links   = dbCategory.OutgoingLinks.Select(x => x.ToCoreModel(retVal)).ToList();


            if (dbCategory.AllParents != null)
            {
                retVal.Parents = dbCategory.AllParents.Select(x => x.ToCoreModel()).ToArray();
                retVal.Level   = retVal.Parents.Count();
            }

            //Try to inherit taxType from parent category
            if (retVal.TaxType == null && retVal.Parents != null)
            {
                retVal.TaxType = retVal.Parents.Select(x => x.TaxType).Where(x => x != null).FirstOrDefault();
            }

            if (dbCategory.Images != null)
            {
                retVal.Images = dbCategory.Images.OrderBy(x => x.SortOrder).Select(x => x.ToCoreModel()).ToList();
            }

            if (convertProps)
            {
                retVal.PropertyValues = dbCategory.CategoryPropertyValues.Select(x => x.ToCoreModel()).ToList();

                var properties = new List <coreModel.Property>();
                //Add inherited from catalog properties
                properties.AddRange(retVal.Catalog.Properties);
                //For parents categories
                if (retVal.Parents != null)
                {
                    properties.AddRange(retVal.Parents.SelectMany(x => x.Properties));
                }
                //Self properties
                properties.AddRange(dbCategory.Properties.Select(x => x.ToCoreModel()));

                //property override - need leave only property has a min distance to target category
                //Algorithm based on index property in resulting list (property with min index will more closed to category)
                var propertyGroups = properties.Select((x, index) => new { PropertyName = x.Name.ToLowerInvariant(), Property = x, Index = index }).GroupBy(x => x.PropertyName);
                retVal.Properties = propertyGroups.Select(x => x.OrderBy(y => y.Index).First().Property).ToList();

                //Next need set Property in PropertyValues objects
                foreach (var propValue in retVal.PropertyValues.ToArray())
                {
                    propValue.Property = retVal.Properties.FirstOrDefault(x => x.IsSuitableForValue(propValue));
                    //Because multilingual dictionary values for all languages may not stored in db then need to add it in result manually from property dictionary values
                    var localizedDictValues = propValue.TryGetAllLocalizedDictValues();
                    foreach (var localizedDictValue in localizedDictValues)
                    {
                        if (!retVal.PropertyValues.Any(x => x.ValueId == localizedDictValue.ValueId && x.LanguageCode == localizedDictValue.LanguageCode))
                        {
                            retVal.PropertyValues.Add(localizedDictValue);
                        }
                    }
                }
            }
            return(retVal);
        }