protected void InitializeCatalogItems() { String items = Request.QueryString["Objects"]; if (String.IsNullOrEmpty(items)) { return; } String[] itemsArray = items.Split(','); List <String> categoryIds = new List <String>(); List <String> productIds = new List <String>(); List <String> linkIds = new List <String>(); List <String> webpageIds = new List <String>(); // Sort out items in saperate lists foreach (String item in itemsArray) { String[] itemValues = item.Split(':'); int catalogNodeId = AlwaysConvert.ToInt(itemValues[0]); CatalogNodeType catalogNodeType = (CatalogNodeType)AlwaysConvert.ToByte(itemValues[1]); switch (catalogNodeType) { case CatalogNodeType.Category: categoryIds.Add(catalogNodeId.ToString()); break; case CatalogNodeType.Product: productIds.Add(catalogNodeId.ToString()); break; case CatalogNodeType.Link: linkIds.Add(catalogNodeId.ToString()); break; case CatalogNodeType.Webpage: webpageIds.Add(catalogNodeId.ToString()); break; } } trIncludeContents.Visible = (categoryIds.Count > 0); if (categoryIds.Count > 0) { ICriteria criteria = CommerceBuilder.DomainModel.NHibernateHelper.CreateCriteria <Category>(); criteria.Add(Restrictions.In("Id", categoryIds.ToArray())); _Categories = CategoryDataSource.LoadForCriteria(criteria); if (_Categories != null && _Categories.Count > 0) { foreach (Category category in _Categories) { _CatalogItems.Add(category); } } } if (productIds.Count > 0) { ICriteria criteria = CommerceBuilder.DomainModel.NHibernateHelper.CreateCriteria <Product>(); criteria.Add(Restrictions.In("Id", productIds.ToArray())); _Products = ProductDataSource.LoadForCriteria(criteria); if (_Products != null && _Products.Count > 0) { foreach (Product product in _Products) { _CatalogItems.Add(product); } } } if (linkIds.Count > 0) { ICriteria criteria = CommerceBuilder.DomainModel.NHibernateHelper.CreateCriteria <Link>(); criteria.Add(Restrictions.In("Id", linkIds.ToArray())); _Links = LinkDataSource.LoadForCriteria(criteria); if (_Links != null && _Links.Count > 0) { foreach (Link link in _Links) { _CatalogItems.Add(link); } } } if (webpageIds.Count > 0) { ICriteria criteria = CommerceBuilder.DomainModel.NHibernateHelper.CreateCriteria <Webpage>(); criteria.Add(Restrictions.In("Id", webpageIds.ToArray())); _Webpages = WebpageDataSource.LoadForCriteria(criteria); if (_Webpages != null && _Webpages.Count > 0) { foreach (Webpage webpage in _Webpages) { _CatalogItems.Add(webpage); } } } if (!Page.IsPostBack) { if (_CatalogItems.Count == 1) { ICatalogable catalogable = _CatalogItems[0]; switch (catalogable.Visibility) { case CatalogVisibility.Public: VisPublic.Checked = true; break; case CatalogVisibility.Private: VisPrivate.Checked = true; break; case CatalogVisibility.Hidden: VisHidden.Checked = true; break; default: VisPrivate.Checked = true; break; } } else if (_CatalogItems.Count > 1) { VisPrivate.Checked = false; VisPublic.Checked = false; VisHidden.Checked = false; } } }