Ejemplo n.º 1
0
        private GenericItem ConvertToGenericItem(IHasOutlines obj, bool convertParents = true)
        {
            GenericItem result = null;

            var category = obj as Category;

            if (category != null)
            {
                result = GetCategoryItem(category.Id, convertParents);
            }

            var product = obj as CatalogProduct;

            if (product != null)
            {
                result = new GenericItem
                {
                    Id            = product.Id,
                    SeoObjectType = product.SeoObjectType,
                    CatalogId     = product.CatalogId,
                    Parents       = new List <GenericItem>(),
                    Links         = new List <CategoryLink>(product.Links),
                };

                if (product.CategoryId != null)
                {
                    var productCategory = GetCategoryItem(product.CategoryId, convertParents);
                    result.Parents.AddRange(productCategory.Parents);
                    result.Parents.Add(productCategory);
                }
            }

            return(result);
        }
Ejemplo n.º 2
0
        public static string[] GetOutlineIds(this IHasOutlines outlineObject)
        {
            var outlineIds = outlineObject.Outlines.SelectMany(o => o.Items)
                             .Select(o => o.Id)
                             .Distinct(StringComparer.OrdinalIgnoreCase)
                             .ToArray();

            return(outlineIds);
        }
Ejemplo n.º 3
0
        private GenericTreeNode <Entity> GetRelationshipsTree(IHasOutlines obj)
        {
            var product  = obj as CatalogProduct;
            var category = obj as Category;
            GenericTreeNode <Entity> retVal = null;

            if (product != null)
            {
                retVal = GetRelationshipsTree(product);
            }
            if (category != null)
            {
                retVal = GetRelationshipsTree(category);
            }
            return(retVal);
        }
Ejemplo n.º 4
0
        private GenericItem ConvertToGenericItem(IHasOutlines obj, bool convertParents = true)
        {
            GenericItem result = null;

            var category = obj as Category;
            if (category != null)
            {
                result = GetCategoryItem(category.Id, convertParents);
            }

            var product = obj as CatalogProduct;
            if (product != null)
            {
                result = new GenericItem
                {
                    Id = product.Id,
                    SeoObjectType = product.SeoObjectType,
                    CatalogId = product.CatalogId,
                    Parents = new List<GenericItem>(),
                    Links = new List<CategoryLink>(product.Links),
                };

                if (product.CategoryId != null)
                {
                    var productCategory = GetCategoryItem(product.CategoryId, convertParents);
                    result.Parents.AddRange(productCategory.Parents);
                    result.Parents.Add(productCategory);
                }
            }

            return result;
        }