コード例 #1
0
        /// <summary>
        /// This adds the missing product features
        /// </summary>
        /// <param name="iproduct"></param>
        /// <param name="productFeaturesToBeAdded"></param>
        private void addProductFeaturesTo(IProduct iproduct, List <ProductFeature> productFeaturesToBeAdded)
        {
            if (productFeaturesToBeAdded.IsNullOrEmpty())
            {
                return;
            }

            Product product = iproduct as Product;

            product.IsNullThrowException("could not unbox product");


            //incase ProductFeatures is null.
            if (product.ProductFeatures.IsNull())
            {
                product.ProductFeatures = new List <ProductFeature>();
            }

            string productId = product.Id;

            foreach (ProductFeature pf in productFeaturesToBeAdded)
            {
                //locate feature in product... if it is not a part of it.. add it
                ProductFeature pfFound = product.ProductFeatures.FirstOrDefault(x => x.Name == pf.Name && x.MetaData.IsDeleted == false);

                if (pfFound.IsNull())
                {
                    pf.ProductId = product.Id;
                    product.ProductFeatures.Add(pf);
                }
            }
        }
コード例 #2
0
        private List <ProductFeature> getProductFeaturesWhichAreInMenuPathButNotInProduct(
            List <ProductFeature> allcurrentProductFeautres,
            List <MenuFeature> allfeautresAsPerMenuPath, IProduct iproduct)
        {
            //if (allcurrentProductFeautres.IsNullOrEmpty())
            //    return null;
            iproduct.IsNullThrowException("iproduct");
            if (allfeautresAsPerMenuPath.IsNullOrEmpty())
            {
                return(null);
            }

            List <ProductFeature> prodFeaturesInMenuButNotInProduct = new List <ProductFeature>();



            foreach (MenuFeature mf in allfeautresAsPerMenuPath)
            {
                ProductFeature pf = null;

                //check to see if mf is part of the current features
                if (!allcurrentProductFeautres.IsNull())
                {
                    //locate if mf is part of the ProductFeatures
                    pf = allcurrentProductFeautres.FirstOrDefault(x => x.Name == mf.Name);
                }


                if (pf.IsNull())
                {
                    pf = ProductFeatureBiz.Factory() as ProductFeature;
                    pf.MenuFeatureId = mf.Id;
                    pf.ProductId     = iproduct.Id;

                    pf.MenuFeature = mf;
                    pf.Product     = iproduct as Product;

                    pf.Name          = pf.MakeUniqueName();
                    pf.IsMenuFeature = true;
                    prodFeaturesInMenuButNotInProduct.Add(pf);
                }
            }

            return(prodFeaturesInMenuButNotInProduct);
        }
コード例 #3
0
ファイル: Bussiness Rules.cs プロジェクト: dovanduy/Library
        public void CreateNewFeature(CreateNewFeatureModel model)
        {
            model.SelfCheck();
            ProductFeature productFeature = ProductFeatureBiz.FindByName(model.FeatureName);

            if (productFeature.IsNull())
            {
                productFeature = ProductFeatureBiz.Factory() as ProductFeature;
                productFeature.IsNullThrowException("productFeature");

                productFeature.Name = model.FeatureName;
                ProductFeatureBiz.CreateAndSave(productFeature);
            }

            //create the new feature.
            Product product = Find(model.ParentId);

            product.IsNullThrowException("product");

            //taking a short cut.
            ProductFeatureModel productFeatureModel = new ProductFeatureModel(model.ParentId, "", productFeature.Id, model.ReturnUrl, model.Description);

            AddFeature(productFeatureModel);
        }