예제 #1
0
        private List <MasterGroupMappingProduct> GetListOfMappedProductsBySourceMasterGroupMapping(MasterGroupMapping productGroup, List <VendorProductInfo> productsPerConnector)
        {
            List <MasterGroupMappingProduct> mappedProducts = new List <MasterGroupMappingProduct>();

            if (productGroup.SourceMasterGroupMappingID.HasValue && productGroup.SourceMasterGroupMappingID.Value > 0)
            {
                if (masterGroupMappingRepo.IsMasterGroupMappingExists(productGroup.SourceMasterGroupMappingID.Value))
                {
                    var currentProductsInMasterGroupMapping = masterGroupMappingRepo.GetListOfMappedProductsByMasterGroupMapping(productGroup.SourceMasterGroupMappingID.Value);

                    var mappedProductsInMasterGroupMapping =
                        (from p in productsPerConnector
                         join mp in currentProductsInMasterGroupMapping on p.ProductID equals mp.ProductID
                         select mp)
                        .ToList();

                    if (mappedProductsInMasterGroupMapping.Count > 0)
                    {
                        mappedProductsInMasterGroupMapping.ForEach(mappedProduct =>
                        {
                            MasterGroupMappingProduct toSyncMasterGroupMappingProduct = new MasterGroupMappingProduct()
                            {
                                MasterGroupMappingID       = productGroup.MasterGroupMappingID,
                                ProductID                  = mappedProduct.ProductID,
                                IsApproved                 = mappedProduct.IsApproved,
                                IsProductMapped            = true,
                                ConnectorPublicationRuleID = productsPerConnector.Where(x => x.ProductID == mappedProduct.ProductID).Select(x => x).FirstOrDefault().ConnectorPublicationRuleID
                            };
                            mappedProducts.Add(toSyncMasterGroupMappingProduct);
                        });
                    }
                }
            }
            return(mappedProducts);
        }
 public bool IsProductGroupValide(MasterGroupMapping productGroup)
 {
     if (productGroup.ParentMasterGroupMappingID.HasValue && productGroup.ParentMasterGroupMappingID.Value > 0)
     {
         List <Product> productInProductGroup = productRepo.GetListOfMappedProductsByMasterGroupMapping(productGroup.MasterGroupMappingID);
         if (productInProductGroup.Count > 0)
         {
             if (masterGroupMappingRepo.IsMasterGroupMappingExists(productGroup.ParentMasterGroupMappingID.Value))
             {
                 //List<Product> productInParentProductGroup = productRepo.GetListOfMappedProductsByMasterGroupMapping(productGroup.ParentMasterGroupMappingID.Value);
                 //if (productInParentProductGroup.Count > 0)
                 //{
                 //  return true;
                 //}
                 return(true);
             }
         }
     }
     return(false);
 }