/// <summary>
        /// Inserts the order and updates the inventory stock.
        /// </summary>
        /// <param name="order">All information about the order</param>
        public void Insert(PetShop.Model.OrderInfo order)
        {
            dal.Insert(order);

            // Update the inventory to reflect the current inventory after the order submission
            Inventory inventory = new Inventory();

            inventory.TakeStock(order.LineItems);
        }
Beispiel #2
0
        /// <summary>
        /// Inserts the order and updates the inventory stock within a transaction.
        /// </summary>
        /// <param name="order">All information about the order</param>
        public void Insert(PetShop.Model.OrderInfo order)
        {
            using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required)) {
                dal.Insert(order);

                // Update the inventory to reflect the current inventory after the order submission
                Inventory inventory = new Inventory();
                inventory.TakeStock(order.LineItems);

                // Calling Complete commits the transaction.
                // Excluding this call by the end of TransactionScope's scope will rollback the transaction
                ts.Complete();
            }
        }
 /// <summary>
 /// This method serializes the order object and send it to the queue for asynchronous processing
 /// </summary>
 /// <param name="order">All information about the order</param>
 public void Insert(PetShop.Model.OrderInfo order)
 {
     asynchOrder.Send(order);
 }