public void StockIncoming(StockIncomingItemCommand command) { Log(string.Format("Received item {0} qty {1}", command.Sku, command.Quantity)); // // Create the item if not found (it's just a sample, should not be applied to a real system) // var item = _repository.GetById<InventoryItem>(command.ItemId); if (!item.HasValidId()) { Log(string.Format("Item {0} Sku {1} is missing.", command.ItemId, command.Sku)); _commandQueue.Enqueue(new CreateInventoryItemCommand(Guid.NewGuid()) { Description = command.Description, ItemId = command.ItemId, Sku = command.Sku }); // push back the command (disclaimer: assuming a single thread processor) // maybe we should change che command id? (check event store concurrency) Log("Requeuing incoming stock request"); _commandQueue.Enqueue(command); return; } item.Stock(command.Quantity); _repository.Save(item, command.Id); //In the previous version we forget to call save Log(string.Format("Item {0} +{1} ", command.Sku, command.Quantity)); }
public void Handle(BillOfLadingConfirmed @event) { var bol = _repository.GetById<BillOfLading>(@event.BillOfLadingId); foreach (var detail in bol.Details) { var cmd = new StockIncomingItemCommand(Guid.NewGuid(), detail.ItemId, detail.Sku, detail.Description, detail.Quantity, IncomingGoodsStorage ); _commandQueue.Enqueue(cmd); } }
/// <summary> /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void ExecuteAddQuantity(object param) { StockIncomingItemCommand command = new StockIncomingItemCommand( Guid.NewGuid(), SelectedInventoryTotalItemView.Id, SelectedInventoryTotalItemView.Sku, "", QuantityToAddToSelectedItem, "ASTORAGE"); Infrastructure.Instance.SendCommand(command); }