protected override async Task <Product> OnExecuteAsync()
 {
     return(await _transactionContext.ExecuteAsync(async() =>
     {
         var product = await _productDataProxy.InsertAsync(CurrentProduct);
         await _inventoryService.InsertCommand(BuildInventoryItem(product)).ExecuteAsync();
         return product;
     }));
 }
Esempio n. 2
0
 protected override async Task OnExecuteAsync()
 {
     await _transactionContext.ExecuteAsync(async() =>
     {
         var result = await _inventoryService.GetByProductCommand(_productID).ExecuteAsync();
         await _inventoryService.DeleteCommand(result.Value.ID).ExecuteAsync();
         await _productDataProxy.DeleteAsync(_productID);
     });
 }
 protected override async Task OnExecuteAsync()
 {
     await _transactionContext.ExecuteAsync(async() =>
     {
         await _orderDataProxy.DeleteAsync(_orderID);
         foreach (var item in CurrentOrderItems)
         {
             await _orderItemService.DeleteCommand(item.ID).ExecuteAsync();
         }
     });
 }
        protected override async Task <OrderItem> OnExecuteAsync()
        {
            return(await _transactionContext.ExecuteAsync(async() =>
            {
                try
                {
                    await _inventoryService.DecrementQuantityOnHandCommand(CurrentOrderItem.ProductID, CurrentOrderItem.Quantity).ExecuteAsync();
                }
                catch (InsufficientStockAmountException)
                {
                    return await _orderItemDataProxy.BackOrderAsync(_orderItemID, DateTime.Now);
                }

                return await _orderItemDataProxy.ShipAsync(_orderItemID, DateTime.Now);
            }));
        }
Esempio n. 5
0
 protected override async Task <OrderItem> OnExecuteAsync()
 {
     return(await _transactionContext.ExecuteAsync(async() =>
     {
         var inventoryItem = await _inventoryDataProxy.GetByProductAsync(CurrentOrderItem.ProductID);
         if (inventoryItem.QuantityOnHand - CurrentOrderItem.Quantity >= 0)
         {
             CurrentOrderItem.OrderStatus().SetShippedState();
             CurrentOrderItem.ShippedDate = DateTime.Now.ToUniversalTime();
             inventoryItem.QuantityOnHand -= CurrentOrderItem.Quantity;
             await _inventoryDataProxy.UpdateAsync(inventoryItem);
         }
         else
         {
             CurrentOrderItem.OrderStatus().SetBackorderedState();
             CurrentOrderItem.BackorderedDate = DateTime.Now.ToUniversalTime();
         }
         return await _orderItemDataProxy.ShipAsync(CurrentOrderItem);
     }));
 }