コード例 #1
0
 /// <summary>
 /// Creates a product
 /// </summary>
 /// <param name="productEntity"></param>
 /// <returns></returns>
 public int CreateProduct(BusinessEntities.ProductEntity productEntity)
 {
     using (var scope = new TransactionScope())
     {
         var product = new productmaster
         {
             ProductName    = productEntity.ProductName,
             ProductTaxable = productEntity.ProductTaxable,
             ProductType    = productEntity.ProductType,
             UnitoMesure    = productEntity.UnitoMesure,
             AlternameUom   = productEntity.AlternameUom,
             TaxType        = productEntity.TaxType,
             Quantity       = productEntity.Quantity,
             Discount       = productEntity.Discount,
             PurchasePrice  = productEntity.PurchasePrice,
             SalePrice      = productEntity.SalePrice,
             Description    = productEntity.Description,
             Hscno          = productEntity.Hscno
         };
         _unitOfWork.ProductMasterRepository.Insert(product);
         _unitOfWork.Save();
         scope.Complete();
         return(product.ProductId);
     }
 }
コード例 #2
0
        /// <summary>
        /// Updates a product
        /// </summary>
        /// <param name="productId"></param>
        /// <param name="productEntity"></param>
        /// <returns></returns>
        public bool UpdateProduct(int productId, BusinessEntities.ProductEntity productEntity)
        {
            var success = false;

            if (productEntity != null)
            {
                using (var scope = new TransactionScope())
                {
                    var product = _unitOfWork.ProductMasterRepository.GetByID(productId);
                    if (product != null)
                    {
                        product.ProductName    = productEntity.ProductName.Trim();
                        product.ProductTaxable = productEntity.ProductTaxable.Trim();
                        product.ProductType    = productEntity.ProductType.Trim();
                        product.UnitoMesure    = productEntity.UnitoMesure.Trim();
                        product.AlternameUom   = productEntity.AlternameUom.Trim();
                        product.TaxType        = productEntity.TaxType.Trim();
                        product.Quantity       = productEntity.Quantity;
                        product.Discount       = productEntity.Discount.Trim();
                        product.PurchasePrice  = productEntity.PurchasePrice;
                        product.SalePrice      = productEntity.SalePrice;
                        product.Description    = productEntity.Description.Trim();
                        product.Hscno          = productEntity.Hscno.Trim();
                        _unitOfWork.ProductMasterRepository.Update(product);
                        _unitOfWork.Save();
                        scope.Complete();
                        success = true;
                    }
                }
            }
            return(success);
        }
コード例 #3
0
        /// <summary>
        /// Creates a product
        /// </summary>
        /// <param name="productEntity"></param>
        /// <returns></returns>
        public int CreateProduct(BusinessEntities.ProductEntity productEntity)
        {
            //using (var scope = new TransactionScope())
            var product = new Product
            {
                ProductName = productEntity.ProductName
            };

            _unitOfWork.ProductRepository.Insert(product);
            _unitOfWork.Save();
            return(product.ProductId);
        }
コード例 #4
0
 /// <summary>
 /// Creates a product
 /// </summary>
 /// <param name="productEntity"></param>
 /// <returns></returns>
 public int CreateProduct(BusinessEntities.ProductEntity productEntity)
 {
     using (var scope = new TransactionScope())
     {
         var product = new Product
         {
             ProductName = productEntity.ProductName
         };
         _unitOfWork.EmployeeRepository.Insert(product);
         _unitOfWork.Save();
         scope.Complete();
         return(product.pkid);
     }
 }
コード例 #5
0
 /// <summary>
 /// 创建产品
 /// Create a new product (CreateProduct) :
 /// This method takes product BusinessEntity as an argument
 /// and creates a new object of actual database entity and insert it using unit of work.
 /// </summary>
 /// <param name="productEntity"></param>
 /// <returns></returns>
 public int CreateProduct(BusinessEntities.ProductEntity productEntity)
 {
     using (var scope = new TransactionScope())  //TransactionScope在System.TransactionScope命名空间下
     {
         var product = new Product()
         {
             ProductName = productEntity.ProductName
         };
         _unitOfWork.ProductRepository.Insert(product);
         _unitOfWork.Save();
         scope.Complete();  //事务完成
         return(product.ProductId);
     }
     //throw new NotImplementedException();
 }
コード例 #6
0
        /// <summary>
        /// Updates a product
        /// </summary>
        /// <param name="productId"></param>
        /// <param name="productEntity"></param>
        /// <returns></returns>
        public bool UpdateProduct(int productId, BusinessEntities.ProductEntity productEntity)
        {
            var success = false;

            if (productEntity != null)
            {
                var product = _unitOfWork.ProductRepository.GetByID(productId);
                if (product != null)
                {
                    product.ProductName = productEntity.ProductName;
                    _unitOfWork.ProductRepository.Update(product);
                    _unitOfWork.Save();
                    success = true;
                }
            }
            return(success);
        }
コード例 #7
0
 /// <summary>
 /// Updates a product
 /// </summary>
 /// <param name="productId"></param>
 /// <param name="productEntity"></param>
 /// <returns></returns>
 public bool UpdateProduct(int productId, BusinessEntities.ProductEntity productEntity)
 {
     if (productEntity == null)
     {
         return(false);
     }
     using (var scope = new TransactionScope())
     {
         var product = _unitOfWork.ProductRepository.GetByID(productId);
         if (product == null)
         {
             return(false);
         }
         product.ProductName = productEntity.ProductName;
         _unitOfWork.ProductRepository.Update(product);
         _unitOfWork.Save();
         scope.Complete();
     }
     return(true);
 }
コード例 #8
0
        /// <summary>
        /// Updates a product
        /// </summary>
        /// <param name="pkid"></param>
        /// <param name="productEntity"></param>
        /// <returns></returns>
        public bool UpdateProduct(int pkid, BusinessEntities.ProductEntity productEntity)
        {
            var success = false;

            if (productEntity != null)
            {
                using (var scope = new TransactionScope())
                {
                    var product = _unitOfWork.EmployeeRepository.GetByID(pkid);
                    if (product != null)
                    {
                        product.ProductName = productEntity.ProductName;
                        _unitOfWork.EmployeeRepository.Update(product);
                        _unitOfWork.Save();
                        scope.Complete();
                        success = true;
                    }
                }
            }
            return(success);
        }
コード例 #9
0
        public bool UpdateProduct(int productId, BusinessEntities.ProductEntity productEntity)
        {
            var success = false;

            if (productEntity != null)
            {
                using (var scope = new TransactionScope())
                {
                    var product = unitOfWork.ProductRepository.GetByID(productId);
                    if (product != null)
                    {
                        product.Name       = productEntity.Name;
                        product.CreateDate = productEntity.CreateDate;
                        product.isActive   = productEntity.isActive;

                        unitOfWork.ProductRepository.Update(product);
                        unitOfWork.Save();
                        scope.Complete();
                        success = true;
                    }
                }
            }
            return(success);
        }