public async Task Handle(CreateOrderCommand command)
 {
     var aggregateId = new OrderAggregateId();
     var order       = new OrderAggregate(aggregateId, command.customerId, command.orderDate, command.orderStatus);
     IDomainEventPublisher <OrderAggregateId>            publisher = new InMemoryDomainEventPublisher <OrderAggregateId>();
     IWriteRepository <OrderAggregate, OrderAggregateId> repo      = new InMemoryWriteRepository <OrderAggregate, OrderAggregateId>(publisher);
     await repo.SaveAsync(order);
 }
예제 #2
0
        public async Task Handle(AddOrderLineItemCommand command)
        {
            IDomainEventPublisher <OrderAggregateId>            publisher = new InMemoryDomainEventPublisher <OrderAggregateId>();
            IWriteRepository <OrderAggregate, OrderAggregateId> repo      = new InMemoryWriteRepository <OrderAggregate, OrderAggregateId>(publisher);
            var orderAggregate = await repo.GetByIdAsync(command.orderAggregateId);

            orderAggregate.AddOrderLineItem(command.productId, command.qty, command.unitPrice);
            await repo.SaveAsync(orderAggregate);
        }
        public async Task Handle(CreateOrderCommand command)
        {
            var aggregateId = new OrderAggregateId();
            var order       = new OrderAggregate(aggregateId, command.customerId, command.orderDate, command.orderStatus);
            IDomainEventPublisher <OrderAggregateId>            publisher = new InMemoryDomainEventPublisher <OrderAggregateId>();
            IWriteRepository <OrderAggregate, OrderAggregateId> repo      = new InMemoryWriteRepository <OrderAggregate, OrderAggregateId>(publisher);
            await repo.SaveAsync(order);

            // foreach (var pe in InMemoryPersistance.publishedEvents) Helpers.SimpleLogger.Log(pe.ToString());
        }