public void Handle(RemoveOrderLine command)
        {
            if (!IsOrderExist(command.OrderId))
            {
                return;
            }

            OrderAggregate orderAggregate = repository.Load <OrderAggregate>(command.OrderId);

            orderAggregate.RemoveLine(command.ProductNumber);
            var aggEvents = new Dictionary <Guid, List <IEvent> >()
            {
                { command.OrderId, orderAggregate.PendingEvents.ToList() }
            };
            Func <Dictionary <Guid, List <IEvent> > > transactionFunc = () => aggEvents;
            Action transactionPostProcessFunc = () => aggEvents.SelectMany(agg => agg.Value).ToList().ForEach(@event => readStorageSyncEventBus.Send(@event));

            repository.Transaction(transactionFunc, transactionPostProcessFunc);
        }
Beispiel #2
0
 public void RemoveLine([FromBody] RemoveOrderLine removeOrderLine)
 {
     commandBus.Send(removeOrderLine);
 }