コード例 #1
0
 public ProductTransaction CreateProductTransaction(ProductTransaction productTransaction)
 {
     try
     {
         var transactionType = GetTransactionTypeById(productTransaction.TransactionTypeId);
         var productInStock  = stockService.GetProductInStockById(productTransaction.StockId, productTransaction.ProductId);
         if (!transactionType.IsIncoming && productInStock.StockQuantity < productTransaction.Quantity)
         {
             throw new LesserStockException();
         }
         productTransaction = productTransactionRepository.Create(productTransaction);
         return(productTransactionRepository.GetById(productTransaction.ProductTransactionId));
     }
     catch (LesserStockException ex)
     {
         throw new LesserStockException(ex.Message);
     }
 }
コード例 #2
0
        public ProductTransaction GetByProductTransactionId(int productTransactionId)
        {
            var productTransaction = productTransactionRepository.GetById(productTransactionId);

            if (productTransaction == null)
            {
                productTransaction = new ProductTransaction();
            }
            return(productTransaction);
        }