Example #1
0
        private Int32 Lookup(InventoryLookupAsyncArgs args)
        {
            Int32 availableInventory            = 0;
            Dictionary <Int32, Int32> warehouse = null;

            if (_warehouses.TryGetValue(args.WarehouseId, out warehouse))
            {
                if (warehouse.TryGetValue(args.ItemId, out availableInventory))
                {
                    if (availableInventory > args.RequestedQty)
                    {
                        availableInventory = args.RequestedQty;
                    }
                }
            }
            return(availableInventory);
        }
Example #2
0
        protected override IAsyncResult BeginExecute(
            AsyncCodeActivityContext context,
            AsyncCallback callback, object state)
        {
            InventoryLookupAsyncArgs parameters = new InventoryLookupAsyncArgs
            {
                ItemId       = ItemId.Get(context),
                WarehouseId  = WarehouseId.Get(context),
                RequestedQty = RequestedQty.Get(context),
            };

            Func <InventoryLookupAsyncArgs, Int32> asyncWork =
                args => Lookup(args);

            context.UserState = asyncWork;
            return(asyncWork.BeginInvoke(parameters, callback, state));
        }