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; }
//private void deleteProductUploadsActually(Product p) //{ // var productUploads = p.MiscFiles; // if (productUploads.IsNullOrEmpty()) // return; // List<string> lstIdsToDelete = new List<string>(); // foreach (var pi in productUploads) // { // lstIdsToDelete.Add(pi.Id); // } // foreach (var id in lstIdsToDelete) // { // UploadedFileBiz.DeleteActuallyAndSave(id); // } // productUploads.Clear(); //} private void deleteProductIdentifiersActually(Product p) { var productIdentifiers = p.ProductIdentifiers; if (productIdentifiers.IsNullOrEmpty()) { return; } List <string> lstIdsToDelete = new List <string>(); foreach (var pi in productIdentifiers) { lstIdsToDelete.Add(pi.Id); } foreach (var id in lstIdsToDelete) { ProductIdentifierBiz.DeleteActuallyAndSave(id); } productIdentifiers.Clear(); }
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(); }