/// <summary>s
 /// Returns catalog's relative outline path
 /// </summary>
 /// <param name="outline"></param>
 /// <returns></returns>
 public static string ToCatalogRelativePath(this catalogDto.Outline outline)
 {
     return(outline.Items == null ? null : string.Join("/",
                                                       outline.Items
                                                       .Where(x => x != null && x.SeoObjectType != "Catalog")
                                                       .Select(x => x.Id)
                                                       ));
 }
        /// <summary>
        /// Returns first outline for given catalog (if any)
        /// </summary>
        /// <param name="outlines"></param>
        /// <param name="catalogId"></param>
        /// <returns></returns>
        public static catalogModel.Outline GetOutlineForCatalog(this IEnumerable <catalogModel.Outline> outlines, string catalogId)
        {
            catalogModel.Outline result = null;

            if (outlines != null)
            {
                // Find any outline for given catalog
                result = outlines.FirstOrDefault(o => o.Items.Any(i => i.SeoObjectType == "Catalog" && i.Id == catalogId));
            }

            return(result);
        }
Example #3
0
        private catalogDto.Outline CreateOutline(catalogDto.Catalog catalog, catalogDto.Category[] categories, catalogDto.Product product = null)
        {
            var result = new catalogDto.Outline
            {
                Items = new List <catalogDto.OutlineItem> {
                    CreateOutlineItem("Catalog", catalog.Id)
                }
            };

            result.Items.AddRange(categories.Select(c => CreateOutlineItem("Category", c.Id, c.CatalogId != catalog.Id)));

            if (product != null)
            {
                result.Items.Add(CreateOutlineItem("CatalogProduct", product.Id));
            }

            return(result);
        }