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(); }
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); }
/// <summary> /// This gets a list of all menu features that need removal. /// </summary> /// <param name="allcurrentProductFeautres"></param> /// <param name="allfeautresAsPerMenuPath"></param> /// <returns></returns> private List <ProductFeature> getProductFeaturesThatNeedToBeRemoved(List <ProductFeature> allcurrentProductFeautres, List <MenuFeature> allfeautresAsPerMenuPath) { if (allcurrentProductFeautres.IsNullOrEmpty()) { return(null); } if (allfeautresAsPerMenuPath.IsNullOrEmpty()) { //remove all the features from the product return(allcurrentProductFeautres); } List <ProductFeature> productFeaturesNotInMenuPath = new List <ProductFeature>(); foreach (ProductFeature pf in allcurrentProductFeautres) { MenuFeature mfFound = allfeautresAsPerMenuPath.FirstOrDefault(x => x.Name == pf.Name); if (mfFound.IsNull()) { //this needs removal productFeaturesNotInMenuPath.Add(pf); } } return(productFeaturesNotInMenuPath); }
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); }
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); }
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); }
public void OnMenuFeatureVisibilityChanged(int visibility, string tag, MenuFeature menuFeature) { if (visibility == (int)SystemUiFlags.Visible) { // Menu feature is visible. } else { // Menu feature is gone. } }
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(); }
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()); }
private void addFeatureToEveryProductWithMenuPath2(MenuPath2 menuPath2, MenuFeature menuFeature) { //Now add the feature to every product that has menu1 as its path. //first find all the menuMains that contain MenuPath1 if (menuPath2.MenuPathMains.IsNullOrEmpty()) { return; } List <MenuPathMain> menuPathMainList = menuPath2.MenuPathMains.ToList(); //Now get all the products that have theseMenuPaths as their path. HashSet <Product> productHashList = new HashSet <Product>(); foreach (var menuPathMain in menuPathMainList) { if (!menuPathMain.Products_Fixed.IsNullOrEmpty()) { List <Product> menuPathMainProductList = menuPathMain.Products_Fixed.ToList(); foreach (var prod in menuPathMainProductList) { productHashList.Add(prod); } } } if (productHashList.IsNullOrEmpty()) { return; } foreach (var prod2 in productHashList) { ProductFeature pf = new ProductFeature(); pf.ProductId = prod2.Id; pf.Product = prod2; pf.MenuFeatureId = menuFeature.Id; pf.MenuFeature = menuFeature; pf.Name = menuFeature.Name; ProductFeatureBiz.CreateAndSave(pf); } SaveChanges(); }
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(); }
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); }