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); }
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); }
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); }
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; }