protected override Product OnExecute()
 {
     return(_transactionContext.Execute(() =>
     {
         var product = _productDataProxy.Insert(CurrentProduct);
         _inventoryService.InsertCommand(BuildInventoryItem(product)).Execute();
         return product;
     }));
 }
 protected override void OnExecute()
 {
     _transactionContext.Execute(() =>
     {
         var item = _inventoryService.GetByProductCommand(_productID).Execute().Value;
         _inventoryService.DeleteCommand(item.ID).Execute();
         _productDataProxy.Delete(_productID);
     });
 }
 protected override void OnExecute()
 {
     _transactionContext.Execute(() =>
     {
         _orderDataProxy.Delete(_orderID);
         CurrentOrderItems.ForEach(i =>
         {
             _orderItemService.DeleteCommand(i.ID).Execute();
         });
     });
 }
        protected override OrderItem OnExecute()
        {
            return(_transactionContext.Execute(() =>
            {
                try
                {
                    _inventoryService.DecrementQuantityOnHandCommand(CurrentOrderItem.ProductID, CurrentOrderItem.Quantity).Execute();
                }
                catch (InsufficientStockAmountException)
                {
                    return _orderItemDataProxy.BackOrder(_orderItemID, DateTime.Now);
                }

                return _orderItemDataProxy.Ship(_orderItemID, DateTime.Now);
            }));
        }
Beispiel #5
0
 protected override OrderItem OnExecute()
 {
     return(_transactionContext.Execute(() =>
     {
         var inventoryItem = _inventoryDataProxy.GetByProduct(CurrentOrderItem.ProductID);
         if (inventoryItem.QuantityOnHand - CurrentOrderItem.Quantity >= 0)
         {
             CurrentOrderItem.OrderStatus().SetShippedState();
             CurrentOrderItem.ShippedDate = DateTime.Now.ToUniversalTime();
             inventoryItem.QuantityOnHand -= CurrentOrderItem.Quantity;
             _inventoryDataProxy.Update(inventoryItem);
         }
         else
         {
             CurrentOrderItem.OrderStatus().SetBackorderedState();
             CurrentOrderItem.BackorderedDate = DateTime.Now.ToUniversalTime();
         }
         return _orderItemDataProxy.Ship(CurrentOrderItem);
     }));
 }