Ejemplo n.º 1
0
        public MenuFeature DeleteMenuPath2ItemFor(string menuFeatureId, string menuPath2Id)
        {
            menuFeatureId.IsNullOrWhiteSpaceThrowArgumentException();
            menuPath2Id.IsNullOrWhiteSpaceThrowArgumentException();

            //make sure that the menuPath is not already a part of the menuFeature
            MenuFeature mf = MenuFeatureBiz.Find(menuFeatureId);

            mf.IsNullThrowException("Not found");

            //MenuPath2 mp2 = mf.MenuPath2s.FirstOrDefault(x => x.Id == menuPath2Id);

            //if (!mp2.IsNull())
            //{
            //    mf.MenuPath2s.Remove(mp2);
            //    mp2.MenuFeatures.Remove(mf);
            //}

            MenuFeatureBiz.SaveChanges();
            MenuFeatureBiz.Detach(mf);//need to do this otherwise local copy (old) is delivered.
            //freshen the data after save
            mf = MenuFeatureBiz.Find(mf.Id);
            mf.IsNullThrowException("Menu Feauture not found!");

            return(mf);
        }
Ejemplo n.º 2
0
        public MenuFeature AddMenu3ItemTo_Save(string menuFeatureId, string menuPath3Id)
        {
            menuFeatureId.IsNullOrWhiteSpaceThrowArgumentException();
            menuPath3Id.IsNullOrWhiteSpaceThrowArgumentException();

            //make sure that the menuPath is not already a part of the menuFeature
            MenuFeature mf = MenuFeatureBiz.Find(menuFeatureId);

            mf.IsNullThrowException("Not found");

            //MenuPath3 mp3 = mf.MenuPath3s.FirstOrDefault(x => x.Id == menuPath3Id);

            //if (mp3.IsNull())
            //{
            //    MenuPath3 _mp3 = MenuPath3Biz.Find(menuPath3Id);
            //    _mp3.IsNullThrowException("Menu Path not found.");

            //    mf.MenuPath3s.Add(mp3);
            //    _mp3.MenuFeatures.Add(mf);
            //    MenuFeatureBiz.Update(mf);
            //}

            MenuFeatureBiz.SaveChanges();
            MenuFeatureBiz.Detach(mf);//need to do this otherwise local copy (old) is delivered.
            //freshen the data after save
            mf = MenuFeatureBiz.Find(mf.Id);
            mf.IsNullThrowException("Menu Feauture not found!");

            return(mf);
        }
Ejemplo n.º 3
0
        public void AddFeature(MenuFeatureModel menuFeatureModel)
        {
            //first get the parent
            menuFeatureModel.SelfCheck();

            MenuPath3 menuPath3 = Find(menuFeatureModel.ParentId);

            menuPath3.IsNullThrowException("menuPath3");

            MenuFeature menuFeature = MenuFeatureBiz.Find(menuFeatureModel.FeatureId);

            menuFeature.IsNullThrowException("menuFeature");

            if (menuFeature.MenuPath3s.IsNull())
            {
                menuFeature.MenuPath3s = new List <MenuPath3>();
            }

            if (menuPath3.MenuFeatures.IsNull())
            {
                menuPath3.MenuFeatures = new List <MenuFeature>();
            }

            menuFeature.MenuPath3s.Add(menuPath3);
            menuPath3.MenuFeatures.Add(menuFeature);
            SaveChanges();
        }
Ejemplo n.º 4
0
        private void saveFeature(MenuFeatureModel menuFeatureModel)
        {
            menuFeatureModel.SelfCheck();
            MenuPath1 menuPath1 = Find(menuFeatureModel.ParentId);

            menuPath1.IsNullThrowException("menuPath1");

            MenuFeature menuFeature = MenuFeatureBiz.Find(menuFeatureModel.FeatureId);

            menuFeature.IsNullThrowException("menuFeature");

            if (menuFeature.MenuPath1s.IsNull())
            {
                menuFeature.MenuPath1s = new List <MenuPath1>();
            }

            if (menuPath1.MenuFeatures.IsNull())
            {
                menuPath1.MenuFeatures = new List <MenuFeature>();
            }

            menuFeature.MenuPath1s.Add(menuPath1);
            menuPath1.MenuFeatures.Add(menuFeature);
            SaveChanges();

            addFeatureToEveryProductWithMenuPath1(menuPath1, menuFeature);
        }
Ejemplo n.º 5
0
        public void AddFeature(MenuFeatureModel menuFeatureModel)
        {
            //first get the parent
            menuFeatureModel.SelfCheck();

            MenuPath2 menuPath2 = Find(menuFeatureModel.ParentId);

            menuPath2.IsNullThrowException("menuPath2");

            MenuFeature menuFeature = MenuFeatureBiz.Find(menuFeatureModel.FeatureId);

            menuFeature.IsNullThrowException("menuFeature");

            if (menuFeature.MenuPath2s.IsNull())
            {
                menuFeature.MenuPath2s = new List <MenuPath2>();
            }

            if (menuPath2.MenuFeatures.IsNull())
            {
                menuPath2.MenuFeatures = new List <MenuFeature>();
            }

            menuFeature.MenuPath2s.Add(menuPath2);
            menuPath2.MenuFeatures.Add(menuFeature);
            SaveChanges();

            addFeatureToEveryProductWithMenuPath2(menuPath2, menuFeature);
        }
Ejemplo n.º 6
0
        public void DeleteFeature(MenuFeatureDeleteModel menuFeatureDeleteModel)
        {
            menuFeatureDeleteModel.SelfCheckIdsAndReturnOnly();

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

            menuFeature.IsNullThrowException("menuFeature");

            MenuPath3 menuPath3 = Find(menuFeatureDeleteModel.MenuPathId);

            menuPath3.IsNullThrowException("menuPath3");



            menuFeature.MenuPath3s.Remove(menuPath3);
            menuPath3.MenuFeatures.Remove(menuFeature);
            SaveChanges();
        }
Ejemplo n.º 7
0
        public void CreateNewFeature(CreateNewFeatureModel model)
        {
            model.SelfCheck();
            MenuFeature menuFeature = MenuFeatureBiz.FindByName(model.FeatureName);

            if (menuFeature.IsNull())
            {
                menuFeature = MenuFeatureBiz.Factory() as MenuFeature;
                menuFeature.IsNullThrowException("menuFeature");

                menuFeature.Name = model.FeatureName;
                MenuFeatureBiz.CreateAndSave(menuFeature);
                return;
            }
            //if you are here then the feature already exists
            ErrorsGlobal.Add(string.Format("'{0}' already exists!", model.FeatureName), MethodBase.GetCurrentMethod());
            throw new Exception(ErrorsGlobal.ToString());
        }
Ejemplo n.º 8
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();
        }
Ejemplo n.º 9
0
        public void CreateNewFeature(CreateNewFeatureModel model)
        {
            model.SelfCheck();
            MenuFeature menuFeature = MenuFeatureBiz.FindByName(model.FeatureName);

            if (menuFeature.IsNull())
            {
                menuFeature = MenuFeatureBiz.Factory() as MenuFeature;
                menuFeature.IsNullThrowException("menuFeature");

                menuFeature.Name = model.FeatureName;
                MenuFeatureBiz.CreateAndSave(menuFeature);
            }
            //create the new feature.

            MenuPath3 menupath3 = Find(model.ParentId);

            menupath3.IsNullThrowException("menupath3");

            //taking a short cut.
            MenuFeatureModel menuFeatureModel = new MenuFeatureModel(model.ParentId, "", menuFeature.Id, model.ReturnUrl);

            AddFeature(menuFeatureModel);
        }