private void CopyProductGroupsToMasterGroupMapping(int productGroupID, int brandProductGroupID) { List <ProductGroup> listOfActiveProductGroups = productGroupRepo.GetListOfActiveProductGroups(); int scoreCounter = 0; listOfActiveProductGroups.ForEach(productGroup => { var productGroupLanguages = productGroupRepo.GetListOfProductGroupLanguagesByProductGroupID(productGroup.ProductGroupID); var vendorProductGroups = productGroupRepo.GetListOfMappedVendorProductGroupsByProductGroupID(productGroup.ProductGroupID); if (productGroupLanguages.Count > 0 && vendorProductGroups.Count > 0) { MasterGroupMapping masterGroupMapping = new MasterGroupMapping() { ProductGroupID = productGroup.ProductGroupID, Score = scoreCounter }; if (vendorProductGroups.Where(x => x.BrandCode == null).Count() > 0) { masterGroupMapping.ParentMasterGroupMappingID = productGroupID; } else { masterGroupMapping.ParentMasterGroupMappingID = brandProductGroupID; } int masterGroupMappingID = masterGroupMappingRepo.InsertMasterGroupMapping(masterGroupMapping); productGroupLanguages.ForEach(language => { MasterGroupMappingLanguage masterGroupMappingLanguage = new MasterGroupMappingLanguage() { MasterGroupMappingID = masterGroupMappingID, LanguageID = language.LanguageID, Name = language.Name }; masterGroupMappingRepo.InsertMasterGroupMappingLanguage(masterGroupMappingLanguage); }); vendorProductGroups.ForEach(vendorProductGroup => { masterGroupMappingRepo.MapVendorProductGroupToMasterGroupMapping(vendorProductGroup.ProductGroupVendorID, masterGroupMappingID); }); scoreCounter++; } }); }