protected void CGrid_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "DeleteItem") { if (CGrid.DataSourceID == "ProductsDs") { int productId = AlwaysConvert.ToInt(e.CommandArgument); Product product = ProductDataSource.Load(productId); if (product != null) { product.Delete(); } } else if (CGrid.DataSourceID == "LinkDs") { int linkId = AlwaysConvert.ToInt(e.CommandArgument); Link link = LinkDataSource.Load(linkId); if (link != null) { link.Delete(); } } else if (CGrid.DataSourceID == "CategoryDs") { int cId = AlwaysConvert.ToInt(e.CommandArgument); Category cat = CategoryDataSource.Load(cId); if (cat != null) { cat.Delete(); } } CGrid.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { _LinkId = AlwaysConvert.ToInt(Request.QueryString["LinkId"]); _Link = LinkDataSource.Load(_LinkId); if (_Link == null) { Response.Redirect("Browse.aspx?CategoryId=" + AbleCommerce.Code.PageHelper.GetCategoryId().ToString()); } if (!Page.IsPostBack) { UpdateCaption(); //NAME Name.Focus(); Name.Text = _Link.Name; //VISIBILITY Visibility.SelectedIndex = (int)_Link.Visibility; //NAVIGATE URL TargetUrl.Text = _Link.TargetUrl; //TARGET ListItem targetItem = TargetWindow.Items.FindByValue(_Link.TargetWindow); if (targetItem != null) { TargetWindow.SelectedIndex = TargetWindow.Items.IndexOf(targetItem); } //THUMBNAIL ThumbnailUrl.Text = _Link.ThumbnailUrl; ThumbnailAltText.Text = _Link.ThumbnailAltText; //SUMARY Summary.Text = _Link.Summary; SummaryCharCount.Text = ((int)(Summary.MaxLength - Summary.Text.Length)).ToString(); Description.Text = _Link.Description; //META MetaKeywordsValue.Text = _Link.MetaKeywords; MetaDescriptionValue.Text = _Link.MetaDescription; MetaDescriptionCharCount.Text = ((int)(MetaDescriptionValue.MaxLength - MetaDescriptionValue.Text.Length)).ToString(); MetaKeywordsCharCount.Text = ((int)(MetaKeywordsValue.MaxLength - MetaKeywordsValue.Text.Length)).ToString(); HtmlHead.Text = _Link.HtmlHead; //DISPLAY PAGE BindDisplayPage(); UpdateDescription(); //THEMES BindThemes(); // SHOW SAVE CONFIRMATION NOTIFICATION IF NEEDED if (Request.UrlReferrer != null && Request.UrlReferrer.AbsolutePath.ToLowerInvariant().EndsWith("addlink.aspx")) { SavedMessage.Visible = true; SavedMessage.Text = string.Format(SavedMessage.Text, LocaleHelper.LocalNow); } } AbleCommerce.Code.PageHelper.ConvertEnterToTab(Name); AbleCommerce.Code.PageHelper.SetMaxLengthCountDown(Summary, SummaryCharCount); AbleCommerce.Code.PageHelper.SetMaxLengthCountDown(MetaDescriptionValue, MetaDescriptionCharCount); AbleCommerce.Code.PageHelper.SetMaxLengthCountDown(MetaKeywordsValue, MetaKeywordsCharCount); }
protected void Page_Load(object sender, EventArgs e) { _LinkId = AbleCommerce.Code.PageHelper.GetLinkId(); _Link = LinkDataSource.Load(_LinkId); if (!Page.IsPostBack) { Caption.Text = string.Format(Caption.Text, _Link.Name); CategoryTree.SelectedCategories = _Link.Categories.ToArray(); } }
protected void Page_PreInit(object sender, EventArgs e) { _Link = LinkDataSource.Load(AbleCommerce.Code.PageHelper.GetLinkId()); if (_Link != null) { if ((_Link.Visibility == CatalogVisibility.Private) && (!AbleContext.Current.User.IsInRole(Role.CatalogAdminRoles))) { Response.Redirect(AbleCommerce.Code.NavigationHelper.GetHomeUrl()); } } else { AbleCommerce.Code.NavigationHelper.Trigger404(Response, "Invalid Link"); } }
public static void FindCatalogable(out ICatalogable catalogable, out CatalogNodeType catalogableType) { HttpContext context = HttpContext.Current; if (context != null) { //CHECK FOR LINK int linkId = AbleCommerce.Code.PageHelper.GetLinkId(); Link link = LinkDataSource.Load(linkId); if (link != null) { catalogable = link; catalogableType = CatalogNodeType.Link; return; } //CHECK FOR WEBPAGE int webpageId = AbleCommerce.Code.PageHelper.GetWebpageId(); Webpage webpage = WebpageDataSource.Load(webpageId); if (webpage != null) { catalogable = webpage; catalogableType = CatalogNodeType.Webpage; return; } //CHECK FOR PRODUCT int productId = AbleCommerce.Code.PageHelper.GetProductId(); Product product = ProductDataSource.Load(productId); if (product != null) { catalogable = product; catalogableType = CatalogNodeType.Product; return; } //CHECK FOR CATEGORY int categoryId = AlwaysConvert.ToInt(context.Request.QueryString["CategoryId"]); Category category = CategoryDataSource.Load(categoryId); if (category != null) { catalogable = category; catalogableType = CatalogNodeType.Category; return; } } catalogable = null; catalogableType = CatalogNodeType.Category; return; }
protected void Page_Load(object sender, EventArgs e) { _LinkId = AbleCommerce.Code.PageHelper.GetLinkId(); _Link = LinkDataSource.Load(_LinkId); if (_Link != null) { string durl = "~/Admin/Catalog/EditLink.aspx?LinkId={0}"; durl = string.Format(durl, _LinkId); string murl = "~/Admin/Catalog/EditLinkCategories.aspx?LinkId={0}"; murl = string.Format(murl, _LinkId); LinkDetails.NavigateUrl = durl; ManageCategories.NavigateUrl = murl; string confirmationJS = String.Format("return confirm('Are you sure you want to delete \\'{0}\\'?');", _Link.Name); DeleteLink.Attributes.Add("onclick", confirmationJS); Preview.NavigateUrl = UrlGenerator.GetBrowseUrl(AbleCommerce.Code.PageHelper.GetCategoryId(), _LinkId, CatalogNodeType.Link, _Link.Name); HighlightMenu(); } else { this.Controls.Clear(); } }
protected void DoDelete(CatalogNodeType catalogNodeType, int catalogNodeId) { switch (catalogNodeType) { case CatalogNodeType.Category: Category category = CategoryDataSource.Load(catalogNodeId); if (category != null) { category.Delete(); } break; case CatalogNodeType.Product: Product product = ProductDataSource.Load(catalogNodeId); if (product != null) { product.Delete(); } break; case CatalogNodeType.Webpage: Webpage webpage = WebpageDataSource.Load(catalogNodeId); if ((webpage != null) && (webpage.Categories.Count < 2)) { webpage.Delete(); } break; case CatalogNodeType.Link: Link link = LinkDataSource.Load(catalogNodeId); if ((link != null) && (link.Categories.Count < 2)) { link.Delete(); } break; } CGrid.DataBind(); }
protected override void CreateChildControls() { bool created = false; Scriptlet Identifier = ScriptletDataSource.Load(this.Page.Theme, this.Identifier, (ScriptletType)Enum.Parse(typeof(ScriptletType), this.ScriptletType), true); string IdentifierScriptletData = string.Empty; if (Identifier != null) { if (!string.IsNullOrEmpty(Identifier.HeaderData)) { this.Page.Header.Controls.Add(new LiteralControl(Identifier.HeaderData)); } IdentifierScriptletData = Identifier.ScriptletData; } string template = IdentifierScriptletData; //PROCESS THE MERGED NVELOCITY TEMPLATE System.Collections.Hashtable parameters = new System.Collections.Hashtable(); object store = Token.Instance.Store; object customer = Token.Instance.User; parameters.Add("store", store); parameters.Add("customer", customer); //TODO: OBSOLETE PARAMETERS, REMOVE FOR AC7.1 parameters.Add("Store", store); parameters.Add("User", customer); //CHECK FOR CATEGORY int categoryId = GetCategoryId(); Category category = CategoryDataSource.Load(categoryId); if (category != null) { parameters.Add("Category", category); } //CHECK FOR PRODUCT int productId = GetProductId(); Product product = ProductDataSource.Load(productId); if (product != null) { parameters.Add("Product", product); } //CHECK FOR WEBPAGE int webpageId = GetWebpageId(); Webpage webpage = WebpageDataSource.Load(webpageId); if (webpage != null) { parameters.Add("Webpage", webpage); } //CHECK FOR LINK int linkId = GetLinkId(); Link link = LinkDataSource.Load(linkId); if (link != null) { parameters.Add("Link", link); } string result = NVelocityEngine.Instance.Process(parameters, template); if (this.Page != null) { string baseUrl = this.Page.ResolveUrl("~"); result = result.Replace("href=\"~/", "href=\"" + baseUrl); result = result.Replace("src=\"~/", "src=\"" + baseUrl); //DISABLE THE ABILITY TO REFER TO ANY USER CONTROL //MatchCollection userControls = Regex.Matches(result, "\\[\\[(ConLib|UserControl):([^\\]]+)\\]\\]", RegexOptions.IgnoreCase); MatchCollection userControls = Regex.Matches(result, "\\[\\[(ConLib):([^\\]]+)\\]\\]", RegexOptions.IgnoreCase); if (userControls.Count > 0) { int currentIndex = 0; foreach (Match match in userControls) { //output the literal content up to the match index if (currentIndex < match.Index) { this.Controls.Add(new LiteralControl(result.Substring(currentIndex, (match.Index - currentIndex)))); currentIndex = match.Index; } string controlPath; Dictionary <string, string> attributes; ParseControlPath(match.Groups[2].Value.Trim(), out controlPath, out attributes); if (match.Groups[1].Value.ToLowerInvariant() == "conlib") { controlPath = "~/ConLib/" + controlPath + ".ascx"; } //LOAD AND OUTPUT THE CONTROL try { Control control = this.Page.LoadControl(controlPath); if (control != null) { //TRY TO SET PARAMS foreach (string propName in attributes.Keys) { //CHECK WHETHER PROPERTY EXISTS System.Reflection.PropertyInfo pi = control.GetType().GetProperty(propName); if (pi != null) { //SET THE PROPERTY WITH THE GIVEN VALUE object value = Convert.ChangeType(attributes[propName], pi.PropertyType); pi.SetValue(control, value, null); } } //ADD CONTROL TO THE COLLECTION this.Controls.Add(control); } } catch (Exception ex) { this.Controls.Add(new LiteralControl(match.Value + " " + ex.Message)); } //advance the current index currentIndex += match.Length; } //output any remaining literal content if (currentIndex < result.Length) { this.Controls.Add(new LiteralControl(result.Substring(currentIndex))); } created = true; } } if (!created) { this.Controls.Add(new LiteralControl(result)); } }
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; } } }
/// <summary> /// Determines the category context for the current request. /// </summary> /// <returns>The category context for the current request.</returns> public static int GetCategoryId() { // LOOK FOR A CATEGORY IN THE QUERY STRING HttpRequest request = HttpContext.Current.Request; int categoryId = AlwaysConvert.ToInt(request.QueryString["CategoryId"]); Category category = CategoryDataSource.Load(categoryId); if (category != null) { return(categoryId); } // LOOK FOR A PRODUCT Product product = ProductDataSource.Load(GetProductId()); if (product != null) { // CHECK PRODUCT CATEGORIES int count = product.Categories.Count; if (count > 0) { if (count > 1) { // CHECK IF LAST VISITED CATEGORY IS ASSOCIATED WITH THIS OBJECT int lastCategoryId = PageVisitHelper.LastVisitedCategoryId; if (product.Categories.Contains(lastCategoryId)) { return(lastCategoryId); } } // RETURN THE FIRST CATEGORY ASSOCIATED WITH THIS OBJECT return(product.Categories[0]); } } // LOOK FOR A WEBPAGE Webpage webpage = WebpageDataSource.Load(GetWebpageId()); if (webpage != null) { int count = webpage.Categories.Count; if (count > 0) { if (count > 1) { // CHECK IF LAST VISITED CATEGORY IS ASSOCIATED WITH THIS OBJECT int lastCategoryId = PageVisitHelper.LastVisitedCategoryId; if (webpage.Categories.Contains(lastCategoryId)) { return(lastCategoryId); } } // RETURN THE FIRST CATEGORY ASSOCIATED WITH THIS OBJECT return(webpage.Categories[0]); } } // LOOK FOR A LINK Link link = LinkDataSource.Load(GetLinkId()); if (link != null) { int count = link.Categories.Count; if (count > 0) { if (count > 1) { // CHECK IF LAST VISITED CATEGORY IS ASSOCIATED WITH THIS OBJECT int lastCategoryId = PageVisitHelper.LastVisitedCategoryId; if (link.Categories.Contains(lastCategoryId)) { return(lastCategoryId); } } // RETURN THE FIRST CATEGORY ASSOCIATED WITH THIS OBJECT return(link.Categories[0]); } } // SEE IF A PARENT CATEGORY ID IS FOUND int parentCategoryId = AlwaysConvert.ToInt(request.QueryString["ParentCategoryId"]); if (parentCategoryId != 0) { return(parentCategoryId); } // NO CATEGORY CONTEXT FOUND return(0); }
private void ProcessRules(BreadCrumbItem breadCrumbItem) { int id; if (breadCrumbItem.Url == "#") { return; } switch (breadCrumbItem.Url.ToLowerInvariant()) { case "~/admin/orders/shipments/editshipment.aspx": id = AlwaysConvert.ToInt(Request.QueryString["OrderShipmentId"]); breadCrumbItem.Url += "?OrderShipmentId=" + id; breadCrumbItem.Title = string.Format(breadCrumbItem.Title, id); break; case "~/admin/products/editproduct.aspx": case "~/admin/products/variants/variants.aspx": case "~/admin/products/variants/options.aspx": case "~/admin/products/digitalgoods/digitalgoods.aspx": case "~/admin/products/kits/editkit.aspx": case "~/admin/products/assets/images.aspx": case "~/admin/products/editproducttemplate.aspx": case "~/admin/products/specials/default.aspx": int categoryId = AbleCommerce.Code.PageHelper.GetCategoryId(); id = AbleCommerce.Code.PageHelper.GetProductId(); Product product = ProductDataSource.Load(id); if (categoryId > 0) { breadCrumbItem.Url += "?CategoryId=" + categoryId + "&ProductId=" + id; } else { breadCrumbItem.Url += "?ProductId=" + id; } breadCrumbItem.Title = string.Format(breadCrumbItem.Title, product.Name); break; case "~/admin/orders/vieworder.aspx": case "~/admin/orders/edit/editorderitems.aspx": case "~/admin/orders/viewdigitalgoods.aspx": case "~/admin/orders/payments/default.aspx": case "~/admin/orders/shipments/default.aspx": id = AbleCommerce.Code.PageHelper.GetOrderId(); Order order = OrderDataSource.Load(id); breadCrumbItem.Url += "?OrderNumber=" + order.OrderNumber; breadCrumbItem.Title = string.Format(breadCrumbItem.Title, order.OrderNumber); break; case "~/admin/marketing/coupons/editcoupon.aspx": id = AlwaysConvert.ToInt(Request.QueryString["CouponId"]); Coupon coupon = CouponDataSource.Load(id); breadCrumbItem.Url += "?CouponId=" + id; breadCrumbItem.Title = string.Format(breadCrumbItem.Title, coupon.Name); break; case "~/admin/products/variants/editoption.aspx": case "~/admin/products/variants/editchoices.aspx": id = AlwaysConvert.ToInt(Request.QueryString["OptionId"]); Option option = OptionDataSource.Load(id); breadCrumbItem.Url += "?OptionId=" + id; breadCrumbItem.Title = string.Format(breadCrumbItem.Title, option.Name); break; case "~/admin/products/giftwrap/editwrapgroup.aspx": id = AlwaysConvert.ToInt(Request.QueryString["WrapGroupId"]); WrapGroup wrapGroup = WrapGroupDataSource.Load(id); breadCrumbItem.Url += "?WrapGroupId=" + id; breadCrumbItem.Title = string.Format(breadCrumbItem.Title, wrapGroup.Name); break; case "~/admin/marketing/email/managelist.aspx": id = AlwaysConvert.ToInt(Request.QueryString["EmailListId"]); EmailList emailList = EmailListDataSource.Load(id); if (emailList != null) { breadCrumbItem.Url += "?EmailListId=" + id; breadCrumbItem.Title = string.Format(breadCrumbItem.Title, emailList.Name); } break; case "~/admin/marketing/discounts/editdiscount.aspx": id = AlwaysConvert.ToInt(Request.QueryString["VolumeDiscountId"]); VolumeDiscount discount = VolumeDiscountDataSource.Load(id); breadCrumbItem.Url += "?VolumeDiscountId=" + id; breadCrumbItem.Title = string.Format(breadCrumbItem.Title, discount.Name); break; case "~/admin/catalog/editwebpage.aspx": id = AbleCommerce.Code.PageHelper.GetWebpageId(); Webpage webpage = WebpageDataSource.Load(id); breadCrumbItem.Url += "?WebpageId=" + id; breadCrumbItem.Title = string.Format(breadCrumbItem.Title, webpage.Name); break; case "~/admin/catalog/editLink.aspx": id = AbleCommerce.Code.PageHelper.GetLinkId(); Link link = LinkDataSource.Load(id); breadCrumbItem.Url += "?LinkId=" + id; breadCrumbItem.Title = string.Format(breadCrumbItem.Title, link.Name); break; case "~/admin/people/users/edituser.aspx": id = AlwaysConvert.ToInt(Request.QueryString["UserId"]); User user = UserDataSource.Load(id); breadCrumbItem.Url += "?UserId=" + id; breadCrumbItem.Title = string.Format(breadCrumbItem.Title, user.UserName); break; case "~/admin/digitalgoods/editdigitalgood.aspx": case "~/admin/digitalgoods/serialkeyproviders/defaultprovider/configure.aspx": id = AlwaysConvert.ToInt(Request.QueryString["DigitalGoodId"]); DigitalGood dg = DigitalGoodDataSource.Load(id); if (dg != null) { breadCrumbItem.Url += "?DigitalGoodId=" + id; breadCrumbItem.Title = string.Format(breadCrumbItem.Title, dg.Name); } break; case "~/admin/products/producttemplates/editproducttemplate.aspx": id = AlwaysConvert.ToInt(Request.QueryString["ProductTemplateId"]); ProductTemplate template = ProductTemplateDataSource.Load(id); if (template == null) { InputField field = InputFieldDataSource.Load(AlwaysConvert.ToInt(Request.QueryString["InputFieldId"])); if (field != null) { template = field.ProductTemplate; id = template.Id; } } if (template != null) { breadCrumbItem.Url += "?ProductTemplateId=" + id; breadCrumbItem.Title = string.Format(breadCrumbItem.Title, template.Name); } else { } break; case "~/admin/reports/dailyabandonedbaskets.aspx": id = AlwaysConvert.ToInt(Request.QueryString["BasketId"]); Basket basket = BasketDataSource.Load(id); if (basket != null) { breadCrumbItem.Url += "?ReportDate=" + basket.User.LastActivityDate.Value.ToShortDateString(); } break; } // resolve relative urls if (breadCrumbItem.Url.StartsWith("~/")) { breadCrumbItem.Url = Page.ResolveUrl(breadCrumbItem.Url); } }
/// <summary> /// Prepare list of used images /// Many be associated with products, as thumbnail, icon, or std. images /// or as additional images /// or to option swathces /// </summary> private void InitAssociatedImageUrls() { associatedImages = new List <string>(); // ADD PRODUCT IMAGES ICriteria criteria = NHibernateHelper.CreateCriteria <Product>(); criteria.Add(Restrictions.Eq("Store", AbleContext.Current.Store)); criteria.Add(Restrictions.Disjunction() .Add(Restrictions.Like("ImageUrl", "~/Assets/ProductImages/%")) .Add(Restrictions.Like("ThumbnailUrl", "~/Assets/ProductImages/%")) .Add(Restrictions.Like("IconUrl", "~/Assets/ProductImages/%"))); IList <Product> products = ProductDataSource.LoadForCriteria(criteria); foreach (Product product in products) { if (product.ImageUrl.StartsWith("~/Assets/ProductImages/")) { associatedImages.Add(product.ImageUrl); } if (product.ThumbnailUrl.StartsWith("~/Assets/ProductImages/")) { associatedImages.Add(product.ThumbnailUrl); } if (product.IconUrl.StartsWith("~/Assets/ProductImages/")) { associatedImages.Add(product.IconUrl); } } // ADDITIONAL IMAGES ICriteria imageCriteria = NHibernateHelper.CreateCriteria <ProductImage>(); imageCriteria.Add(Restrictions.Like("ImageUrl", "~/Assets/ProductImages/%")); IList <ProductImage> images = ProductImageDataSource.LoadForCriteria(imageCriteria); foreach (ProductImage image in images) { associatedImages.Add(image.ImageUrl); } // OPTION SWATCHES ICriteria choicesCriteria = NHibernateHelper.CreateCriteria <OptionChoice>(); choicesCriteria.Add(Restrictions.Disjunction() .Add(Restrictions.Like("ImageUrl", "~/Assets/ProductImages/%")) .Add(Restrictions.Like("ThumbnailUrl", "~/Assets/ProductImages/%"))); IList <OptionChoice> choices = OptionChoiceDataSource.LoadForCriteria(choicesCriteria); foreach (OptionChoice choice in choices) { if (choice.ImageUrl.StartsWith("~/Assets/ProductImages/")) { associatedImages.Add(choice.ImageUrl); } if (choice.ThumbnailUrl.StartsWith("~/Assets/ProductImages/")) { associatedImages.Add(choice.ThumbnailUrl); } } // ADD CATEGORY IMAGES ICriteria categoryCriteria = NHibernateHelper.CreateCriteria <Category>(); categoryCriteria.Add(Restrictions.Eq("Store", AbleContext.Current.Store)); categoryCriteria.Add(Restrictions.Like("ThumbnailUrl", "~/Assets/ProductImages/%")); IList <Category> categories = CategoryDataSource.LoadForCriteria(categoryCriteria); foreach (Category category in categories) { if (category.ThumbnailUrl.StartsWith("~/Assets/ProductImages/")) { associatedImages.Add(category.ThumbnailUrl); } } // ADD LINK IMAGES ICriteria linksCriteria = NHibernateHelper.CreateCriteria <Link>(); linksCriteria.Add(Restrictions.Eq("Store", AbleContext.Current.Store)); linksCriteria.Add(Restrictions.Like("ThumbnailUrl", "~/Assets/ProductImages/%")); IList <Link> links = LinkDataSource.LoadForCriteria(linksCriteria); foreach (Link link in links) { if (link.ThumbnailUrl.StartsWith("~/Assets/ProductImages/")) { associatedImages.Add(link.ThumbnailUrl); } } // ADD GIFT WRAPING IMAGES ICriteria wrapstylesCriteria = NHibernateHelper.CreateCriteria <WrapStyle>(); wrapstylesCriteria.Add(Restrictions.Like("ImageUrl", "~/Assets/ProductImages/%")); IList <WrapStyle> wrapStyles = WrapStyleDataSource.LoadForCriteria(wrapstylesCriteria); foreach (WrapStyle ws in wrapStyles) { if (ws.ImageUrl.StartsWith("~/Assets/ProductImages/")) { associatedImages.Add(ws.ImageUrl); } if (ws.ThumbnailUrl.StartsWith("~/Assets/ProductImages/")) { associatedImages.Add(ws.ThumbnailUrl); } } // ADD VARIANT IMAGES ICriteria variantsCriteria = NHibernateHelper.CreateCriteria <ProductVariant>(); criteria.Add(Restrictions.Disjunction() .Add(Restrictions.Like("ImageUrl", "~/Assets/ProductImages/%")) .Add(Restrictions.Like("ThumbnailUrl", "~/Assets/ProductImages/%")) .Add(Restrictions.Like("IconUrl", "~/Assets/ProductImages/%"))); int variantsCount = ProductVariantDataSource.CountForCriteria(variantsCriteria.Clone() as ICriteria); int maxVariantsToCache = 500; // avoid loading all variants at same time for (int index = 0; index < variantsCount; index += maxVariantsToCache) { variantsCriteria.SetMaxResults(maxVariantsToCache); variantsCriteria.SetFirstResult(index); IList <ProductVariant> productVariants = ProductVariantDataSource.LoadForCriteria(variantsCriteria); foreach (ProductVariant productVariant in productVariants) { if (productVariant.ImageUrl.StartsWith("~/Assets/ProductImages/")) { associatedImages.Add(productVariant.ImageUrl); } if (productVariant.ThumbnailUrl.StartsWith("~/Assets/ProductImages/")) { associatedImages.Add(productVariant.ThumbnailUrl); } if (productVariant.IconUrl.StartsWith("~/Assets/ProductImages/")) { associatedImages.Add(productVariant.IconUrl); } } } }
protected void DoDelete(CatalogNodeType catalogNodeType, int catalogNodeId) { switch (catalogNodeType) { case CatalogNodeType.Category: Category category = CategoryDataSource.Load(catalogNodeId); if (category != null) { category.Delete(); } break; case CatalogNodeType.Product: Product product = ProductDataSource.Load(catalogNodeId); if (product != null) { if (product.Categories.Count > 1) { product.Categories.Remove(CurrentCategory.Id); product.Categories.Save(); } else { product.Delete(); } } break; case CatalogNodeType.Webpage: Webpage webpage = WebpageDataSource.Load(catalogNodeId); if (webpage != null) { if (webpage.Categories.Count > 1) { webpage.Categories.Remove(CurrentCategory.Id); webpage.Categories.Save(); } else { webpage.Delete(); } } break; case CatalogNodeType.Link: Link link = LinkDataSource.Load(catalogNodeId); if (link != null) { if (link.Categories.Count > 1) { link.Categories.Remove(CurrentCategory.Id); link.Categories.Save(); } else { link.Delete(); } } break; } }