예제 #1
0
        public int SetProduct(Product product)
        {
            _logger.Info($"BLL.{nameof(ProductBll)}.{nameof(SetProduct)}: Retention of the product");

            if (product.Category != null)
            {
                _logger.Info($"BLL.{nameof(ProductBll)}.{nameof(SetProduct)}: Category discovered");

                product.Category.Id = _categoryBll.SetCategory(product.Category);
            }
            else
            {
                _logger.Info($"BLL.{nameof(ProductBll)}.{nameof(SetProduct)}: Category not discovered");
            }

            if (product.Id != null)
            {
                int id = _productDao.ChangeProduct(product);

                _logger.Info($"BLL.{nameof(ProductBll)}.{nameof(SetProduct)}: Product id = {id} changed");

                return(id);
            }
            else
            {
                int id = _productDao.AddProduct(product);

                _logger.Info($"BLL.{nameof(ProductBll)}.{nameof(SetProduct)}: Product id = {id} added");

                return(id);
            }
        }
        public int SetCommodityUnit(CommodityUnit commodityUnit)
        {
            _logger.Info($"BLL.{nameof(CommodityUnitBll)}.{nameof(SetCommodityUnit)}: Retention of commodity unit");

            if (commodityUnit.Product != null)
            {
                _logger.Info($"BLL.{nameof(CommodityUnitBll)}.{nameof(SetCommodityUnit)}: Product discovered");

                commodityUnit.Product.Id = _productBll.SetProduct(commodityUnit.Product);

                if (commodityUnit.Product.Category != null)
                {
                    _logger.Info($"BLL.{nameof(CommodityUnitBll)}.{nameof(SetCommodityUnit)}: Category discovered");

                    commodityUnit.Product.Category.Id = _categoryBll.SetCategory(commodityUnit.Product.Category);
                }
                else
                {
                    _logger.Info($"BLL.{nameof(CommodityUnitBll)}.{nameof(SetCommodityUnit)}: Category not discovered");
                }
            }
            else
            {
                _logger.Info($"BLL.{nameof(CommodityUnitBll)}.{nameof(SetCommodityUnit)}: Product not discovered");
            }

            if (commodityUnit.Status != null)
            {
                _logger.Info($"BLL.{nameof(CommodityUnitBll)}.{nameof(SetCommodityUnit)}: Status discovered");

                commodityUnit.Status.Id = _statusBll.SetStatus(commodityUnit.Status);
            }
            else
            {
                _logger.Info($"BLL.{nameof(CommodityUnitBll)}.{nameof(SetCommodityUnit)}: Status not discovered");
            }

            if (commodityUnit.Store != null)
            {
                _logger.Info($"BLL.{nameof(CommodityUnitBll)}.{nameof(SetCommodityUnit)}: Store discovered");

                commodityUnit.Store.Id = _storeBll.SetStore(commodityUnit.Store);
            }
            else
            {
                _logger.Info($"BLL.{nameof(CommodityUnitBll)}.{nameof(SetCommodityUnit)}: Store not discovered");
            }

            if (commodityUnit.Vendor != null)
            {
                _logger.Info($"BLL.{nameof(CommodityUnitBll)}.{nameof(SetCommodityUnit)}: Vendor discovered");

                commodityUnit.Vendor.Id = _vendorBll.SetVendor(commodityUnit.Vendor);
            }
            else
            {
                _logger.Info($"BLL.{nameof(CommodityUnitBll)}.{nameof(SetCommodityUnit)}: Vendor not discovered");
            }

            if (commodityUnit.Id != null)
            {
                int id = _commodityUnitDao.ChangeCommodityUnit(commodityUnit);

                _logger.Info($"BLL.{nameof(CommodityUnitBll)}.{nameof(SetCommodityUnit)}: Commodity unit id = {id} changed");

                return(id);
            }
            else
            {
                int id = _commodityUnitDao.AddCommodityUnit(commodityUnit);

                _logger.Info($"BLL.{nameof(CommodityUnitBll)}.{nameof(SetCommodityUnit)}: Commodity unit id = {id} added");

                return(id);
            }
        }