private List <CheckBoxItem> CreateCheckBoxes() { List <MenuPathMain> allMenuPaths = MenuPathMainBiz.FindAll().ToList(); //Now create all the check boxes List <CheckBoxItem> checkedboxes = createAllCheckBoxes(allMenuPaths); return(checkedboxes); }
/// <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); } }
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(); }