public bool DeleteProductImage(int storeID, ProductImage pi) {
            try {
                this._sessionManager.OpenSession().Delete(pi);
                this._sessionManager.OpenSession().Flush();
            } catch (Exception e) {
                LogManager.GetLogger(GetType()).Error(e);
                return false;
            }

            return true;
        }
        public bool SaveEditedProduct(DbProduct p, List<ProductAttributeOptionValue> paovList, List<IImage> images, List<ProductRelation> crossSellList, List<ProductDocument> documentList, List<ProductSynonym> synonymList) {

            bool isNewProduct = (p.ProductID == 0);

            CatalogueViewModule controller = Module as CatalogueViewModule;
        	try
        	{
        		controller.EditService.SaveProduct(1, p);
				productEditor.txtProductID.Text = p.ProductID.ToString();
        	}
        	catch (Exception)
        	{
				return false;
        	}

            if (isNewProduct) {
                
                ProductCategory pc = new ProductCategory();
                pc.CategoryID = CatID;
                pc.ProductID = p.ProductID;
                pc.Product = p;
                
                if (!controller.EditService.SaveProductCategory(1, "", pc)) {
                    return false;
                }
            }

            if (p.Images != null) {
                foreach (ProductImage pi in p.Images) {
                    controller.EditService.DeleteProductImage(1, pi);
                }
            }

            if (images != null) {
                foreach (IImage i in images) {
                    ProductImage pi = new ProductImage();
                    ImageHelper.CopyImage(i, pi);
                    pi.ProductID = p;
                    pi.ProductID.ProductID = p.ProductID;
                    controller.EditService.SaveProductImage(1, pi);
                }
            }

            if (p.RelatedProducts != null) {
                foreach (ProductRelation pr in p.RelatedProducts) {
                    controller.EditService.DeleteProductRelation(controller.Section.Node.Site.Id, pr);
                }
            }

            if (crossSellList != null) {
                foreach (ProductRelation pr in crossSellList) {
                    controller.EditService.SaveProductRelation(1, pr);
                }
            }

            if (p.Documents != null) {
                foreach (ProductDocument d in p.Documents) {
                    if (!controller.EditService.DeleteProductDocument(controller.Section.Node.Site.Id, controller.Section.Node.Culture, d)) {
                        return false;
                    }
                }
            }

            if (documentList != null) {
                foreach (ProductDocument pd in documentList) {
                    if (!controller.EditService.SaveProductDocument(controller.Section.Node.Site.Id, controller.Section.Node.Culture, pd)) {
                        return false;
                    }
                }
            }

            if (p.Synonyms != null) {
                foreach (ProductSynonym ps in p.Synonyms) {
                    if (!controller.EditService.DeleteProductSynonym(controller.Section.Node.Site.Id, controller.Section.Node.Culture, ps)) {
                        return false;
                    }
                }
            }

            if (synonymList != null) {
                foreach (ProductSynonym ps in synonymList) {
                    if (!controller.EditService.SaveProductSynonym(controller.Section.Node.Site.Id, controller.Section.Node.Culture, ps)) {
                        return false;
                    }
                }
            }
            
            return true;
        }