public async Task <IEnumerable <Event> > ProcessAsync(Event evnt) { var itemBackInStockForOrder = evnt.GetBody <ItemBackInStockForOrder>(); var parkedItems = (await _parkedOrderItemsStore.GetAsync("ProductQueuedForOrder", itemBackInStockForOrder.OrderId)).ToArray(); var parkedOrderItem = parkedItems.Single(x => x.ProductId == itemBackInStockForOrder.ProductId); parkedOrderItem.IsItemReadyToShip = true; _parkedOrderItemsStore.UpdateAsync("ProductQueuedForOrder", itemBackInStockForOrder.OrderId, parkedOrderItem); if (parkedItems.Any(x => !x.IsItemReadyToShip)) { Trace.TraceInformation("ItemBackInStockForOrderActor - still items remaining"); return(new Event [0]); } else // ready { Trace.TraceInformation("ItemBackInStockForOrderActor - itemss all OK"); return(new[] { new Event(new OrderInventoryCheckCompleted() { OrderId = itemBackInStockForOrder.OrderId }) }); } }
public async Task <IEnumerable <Event> > ProcessAsync(Event evnt) { var productArrivedBackInStock = evnt.GetBody <ProductArrivedBackInStock>(); var orders = await _ordersWaitingProvider.GetAsync("OrderQueuedForProduct", productArrivedBackInStock.ProductId); _ordersWaitingProvider.RemoveAsync("OrderQueuedForProduct", productArrivedBackInStock.ProductId).Wait(); return(orders.Select(x => new Event(new ItemBackInStockForOrder() { ProductId = productArrivedBackInStock.ProductId, OrderId = x.OrderId }))); }