public void InitializeFromEnumAndSave() { var listOfEnums = EnumExtention <ProductCategory1ENUM> .ToList(); if (listOfEnums.IsNullOrEmpty()) { return; } listOfEnums.Remove(ProductCategory1ENUM.Unknown.ToString()); CreateEntitiesFromListOfStrings(listOfEnums as IList <string>); Save(); ProductCategoryMainDAL pCatMainDal = new ProductCategoryMainDAL(_db, _user); //remember to create the MainProduct also for these categories foreach (var item in listOfEnums) { try { ProductCategoryMain c = pCatMainDal.Factory(); c.ProductCat1 = (ICategory)FindForName(item); pCatMainDal.Create(c); pCatMainDal.Save(); } catch (ErrorHandlerLibrary.ExceptionsNS.NoDuplicateException) { continue; } } Save(); }
private void Fix_Product_Category(Product entity) { if (entity.ProdCategory == null) { if (entity.UomStockID.IsNullOrEmpty()) { //throw new Exception(string.Format("Product Category not found for product: {0}. 1.ProductDAL.Fix_Product_Category", entity.FullName())); } else { var x = new ProductCategoryMainDAL(_db, _user).FindFor(entity.UomStockID); if (x == null) { throw new Exception(string.Format("Uom Purchase not found for product: {0}. 2.ProductDAL.Fix_Product_Category", entity.FullName())); } } } else { if (entity.UomShipWeightId.IsNullOrEmpty()) { entity.UomShipWeightId = entity.UomShipWeight.Id; } } }