private short GetNodeIndex(DbProduct product, IList productCatList) { short sortOrder = Domain.ProductCategory.SORT_ORDER_MIN; int storeID = controller.Section.Node.Site.Id; short productCatIndex = 0; //Perform quick sanity check on sort orders whilst we're at it foreach (ProductCategory node in productCatList) { if (node.SortOrder != sortOrder) { node.SortOrder = sortOrder; controller.EditService.MoveProduct(storeID, node); } //Work out index of our node in list if (node.ProductID == product.ProductID) { productCatIndex = (short)(sortOrder - Domain.ProductCategory.SORT_ORDER_MIN); } sortOrder++; } return productCatIndex; }
private void MoveDown(DbProduct product) { if (product.Categories.Count == 0) { return; } ProductCategory pc = null; foreach (ProductCategory productCategory in product.Categories) { if (productCategory.CategoryID == CatID) { pc = productCategory; } } IList productCatList = controller.CatalogueViewer.GetECommerceProductsByCategory(controller.Section.Node.Site.Id, controller.Section.Node.Culture, pc.CategoryID); //Check the sort orders make sense short productCatIndex = GetNodeIndex(product, productCatList); //Make sure it's not the bottom one if (productCatIndex == (productCatList.Count - 1)) { return; } SwapProducts(productCatList, productCatIndex); }