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); } }
public ProductTransaction GetByProductTransactionId(int productTransactionId) { var productTransaction = productTransactionRepository.GetById(productTransactionId); if (productTransaction == null) { productTransaction = new ProductTransaction(); } return(productTransaction); }