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)); }
protected override int Execute(CodeActivityContext context) { Int32 availableInventory = 0; Int32 warehouseId = WarehouseId.Get(context); Dictionary <Int32, Int32> warehouse = null; if (_warehouses.TryGetValue(warehouseId, out warehouse)) { Int32 itemId = ItemId.Get(context); if (warehouse.TryGetValue(itemId, out availableInventory)) { Int32 requestedQty = RequestedQty.Get(context); if (availableInventory > requestedQty) { availableInventory = requestedQty; } } } return(availableInventory); }