Пример #1
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);
        }
Пример #2
0
        private void saveFeature(ProductFeatureModel productFeatureModel)
        {
            productFeatureModel.SelfCheck();

            Product product = Find(productFeatureModel.ParentId);

            product.IsNullThrowException("product");

            MenuFeature menuFeature = MenuFeatureBiz.Find(productFeatureModel.MenuFeatureId);

            menuFeature.IsNullThrowException("Menu feature not found.");

            //create a new product Feature and add it
            ProductFeature productFeature = ProductFeatureBiz.Factory() as ProductFeature;

            productFeature.ProductId     = product.Id;
            productFeature.MenuFeatureId = menuFeature.Id;
            productFeature.Comment       = productFeatureModel.Description;
            productFeature.Name          = menuFeature.FullName();

            product.ProductFeatures.Add(productFeature);
            SaveChanges();
        }
Пример #3
0
        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);
        }