private void ShareProducts() { var settings = ModCtrl.GetByGuidKey(PortalSettings.Current.PortalId, 0, "SETTINGS", "NBrightBuySettings"); if (settings != null) { StoreSettings.Refresh(); // make sure we pickup changes. var shareproducts = StoreSettings.Current.GetBool("shareproducts"); var sharedproductsflag = StoreSettings.Current.GetBool("sharedproductsflag"); if (shareproducts) { // we only want to do this if the shareproducts has changed, so use a flag. if (!sharedproductsflag) { var l = ModCtrl.GetList(PortalId, -1, "PRD"); foreach (var i in l) { SharedRecord(i); } l = ModCtrl.GetList(PortalId, -1, "PRDLANG"); foreach (var i in l) { SharedRecord(i); } l = ModCtrl.GetList(PortalId, -1, "CATEGORY"); foreach (var i in l) { SharedRecord(i); } l = ModCtrl.GetList(PortalId, -1, "CATEGORYLANG"); foreach (var i in l) { SharedRecord(i); } settings.SetXmlProperty("genxml/checkbox/sharedproductsflag", "True"); // set flag ModCtrl.Update(settings); } } else { // test if want to reverse the share products, by using the flag. if (sharedproductsflag) { var l = ModCtrl.GetList(PortalId, -1, "PRD"); foreach (var i in l) { UnSharedRecord(i); } l = ModCtrl.GetList(PortalId, -1, "PRDLANG"); foreach (var i in l) { UnSharedRecord(i); } l = ModCtrl.GetList(PortalId, -1, "CATEGORY"); foreach (var i in l) { UnSharedRecord(i); } l = ModCtrl.GetList(PortalId, -1, "CATEGORYLANG"); foreach (var i in l) { UnSharedRecord(i); } settings.SetXmlProperty("genxml/checkbox/sharedproductsflag", "False"); // set flag ModCtrl.Update(settings); } } } }