private List <CheckBoxItem> CreateCheckBoxes() { List <MenuPathMain> allMenuPaths = MenuPathMainBiz.FindAll().ToList(); //Now create all the check boxes List <CheckBoxItem> checkedboxes = createAllCheckBoxes(allMenuPaths); return(checkedboxes); }
/// <summary> /// When the Product is created from the productMenu, then its; menuPathMainId is sent along with it /// This will be its first MenuPathMain. User can add more as required. /// </summary> /// <param name="parm"></param> /// <param name="product"></param> private void addMenuPathMainSentFromView(ControllerIndexParams parm, Product product) { if (!parm.MenuPathMainId.IsNullOrWhiteSpace()) { if (product.MenuPathMains.IsNull()) { product.MenuPathMains = new List <MenuPathMain>(); } MenuPathMain mpm = MenuPathMainBiz.Find(parm.MenuPathMainId); mpm.IsNullThrowException("Menu Path main not found"); product.MenuPathMains.Add(mpm); } }
/// <summary> /// This adds all the selected Menu Paths. /// </summary> /// <param name="iproduct"></param> private void addSelectedMenuPathMain(IProduct iproduct) { Product product = iproduct as Product; product.IsNullThrowException("Product could not be boxed."); List <CheckBoxItem> selectedPaths = product.CheckedBoxesList.Where(x => x.IsTrue == true).ToList(); //there are none to add if (selectedPaths.IsNullOrEmpty()) { return; } if (product.MenuPathMains.IsNull()) { product.MenuPathMains = new List <MenuPathMain>(); } //Now add the selected paths to the product. foreach (var cbi in selectedPaths) { //first check to see if the selected path is part of the product. MenuPathMain mpm = product.MenuPathMains.FirstOrDefault(x => x.Id == cbi.Id); //Path has been found. It is already a part of the product. if (!mpm.IsNull()) { continue; } mpm = MenuPathMainBiz.FindAll().FirstOrDefault(x => x.Id == cbi.Id); mpm.IsNullThrowException("Main path not found! Programming error."); product.MenuPathMains.Add(mpm); mpm.Products.Add(product); Update(product); MenuPathMainBiz.Update(mpm); } }
public MyWorkClassesProduct( UomVolumeBiz uomVolumeBiz, UomLengthBiz uomLengthBiz, UomQuantityBiz uomQuantityBiz, UomWeightBiz uomWeightBiz, MenuPathMainBiz menuPathMainBiz, ProductIdentifierBiz productIdentifierBiz, //ProductChildBiz productChildBiz, ProductFeatureBiz productFeatureBiz, MenuFeatureBiz menuFeatureBiz) { _uomVolumeBiz = uomVolumeBiz; _uomLengthBiz = uomLengthBiz; _uomQuantityBiz = uomQuantityBiz; _uomWeightBiz = uomWeightBiz; _menuPathMainBiz = menuPathMainBiz; _productIdentifierBiz = productIdentifierBiz; //_productChildBiz = productChildBiz; _productFeatureBiz = productFeatureBiz; _menuFeatureBiz = menuFeatureBiz; }
//public void DeleteFeature(ProductFeatureDeleteModel productFeatureDeleteModel) //{ // productFeatureDeleteModel.SelfCheckIdsAndReturnOnly(); // ProductFeature productFeature = ProductFeatureBiz.Find(productFeatureDeleteModel.ProductFeatureId); // productFeature.IsNullThrowException("productFeature"); // Product product = Find(productFeatureDeleteModel.ProductId); // product.IsNullThrowException("product"); // productFeature.Products.Remove(product); // product.ProductFeatures.Remove(productFeature); // SaveChanges(); //} public void FixMenuPaths(ControllerIndexParams parm) { if (parm.MenuPathMainId.IsNullOrWhiteSpace()) { return; } parm.Entity.IsNullThrowExceptionArgument("Entity"); string menuPathMainId = parm.MenuPathMainId; Product product = parm.Entity as Product; product.IsNullThrowException("product"); //get the menuPath MenuPathMain mpm = MenuPathMainBiz.Find(menuPathMainId); mpm.IsNullThrowException("mpm"); product.MenuPathMains.Add(mpm); product.MainMenuIdForShop = mpm.Id; }
private void addProducts() { //get the data List <ProductInitializerHelper> dataList = GetDataListForProduct; if (!dataList.IsNullOrEmpty()) { foreach (ProductInitializerHelper prodInitHelper in dataList) { //check to see if the product exists... if it does continue. Product p = FindByName(prodInitHelper.Name); if (!p.IsNull()) { continue; } p = new Product(); p.Name = prodInitHelper.Name; p.IsUnApproved = false; //p.UomVolume = UomVolumeBiz.FindByName(prodInitHelper.UomVolumeName); //p.UomVolume.IsNullThrowException(); //p.UomDimensions = UomLengthBiz.FindByName(prodInitHelper.UomLengthName); //p.UomDimensions.IsNullThrowException(); //p.UomWeightActual = UomWeightBiz.FindByName(prodInitHelper.UomShipWeightName); //p.UomWeightListed = UomWeightBiz.FindByName(prodInitHelper.UomWeightListedName); //p.UomWeightListed.IsNullThrowException(); //p.UomPurchase = UomQuantityBiz.FindByName(prodInitHelper.UomPurchaseName); //p.UomPurchase.IsNullThrowException(); //p.UomSale = UomQuantityBiz.FindByName(prodInitHelper.UomSaleName); //p.UomSale.IsNullThrowException(); //p.Dimensions.Height = prodInitHelper.Height; //p.Dimensions.Width = prodInitHelper.Width; //p.Dimensions.Length = prodInitHelper.Length; //p.UomDimensionsId = p.UomDimensions.Id; //p.UomVolumeId = p.UomVolume.Id; //p.UomDimensionsId = p.UomDimensions.Id; //p.WeightActual = prodInitHelper.ShipWeight; //p.UomWeightActualId = p.UomWeightActual.Id; //p.UomWeightListedId = p.UomWeightListed.Id; //p.UomPurchaseId = p.UomPurchase.Id; //p.UomSaleId = p.UomSale.Id; //p.WeightListed = prodInitHelper.WeightListed; //p.Volume = prodInitHelper.ShipVolume; if (ErrorsGlobal.HasErrors) { throw new Exception(ErrorsGlobal.ToString()); } #region Menu Path if (prodInitHelper.Menupaths.IsNull()) { } else { foreach (MenuPathHelper mph in prodInitHelper.Menupaths) { MenuPathMain mpm = MenuPathMainBiz.FindAll().FirstOrDefault(x => x.MenuPath1.Name.ToLower() == mph.MenuPath1Name.ToLower() && x.MenuPath2.Name.ToLower() == mph.MenuPath2Name.ToLower() && x.MenuPath3.Name.ToLower() == mph.MenuPath3Name.ToLower()); if (mpm.IsNull()) { continue; } if (p.MenuPathMains.IsNull()) { p.MenuPathMains = new List <MenuPathMain>(); } p.MenuPathMains.Add(mpm); if (mpm.Products.IsNull()) { mpm.Products = new List <Product>(); } mpm.Products.Add(p); } } #endregion #region ProductIdentifier if (prodInitHelper.ProductIdentifiers.IsNull()) { } else { foreach (string piStr in prodInitHelper.ProductIdentifiers) { ProductIdentifier pi = ProductIdentifierBiz.Find(piStr); if (!pi.IsNull()) { throw new Exception(string.Format("Duplicate product Identifier: '{0}'", piStr)); } pi = ProductIdentifierBiz.Factory() as ProductIdentifier; pi.Name = piStr; pi.Product = p; pi.ProductId = p.Id; if (p.ProductIdentifiers.IsNull()) { p.ProductIdentifiers = new List <ProductIdentifier>(); } p.ProductIdentifiers.Add(pi); } } #endregion CreateSave_ForInitializeOnly(p); } } AddInitData_ProductChild(); }