Exemple #1
0
        public void Handle(CreateOrderRequest command)
        {
            OrderAggregate order = AggregateFactory.Create <OrderAggregate>();

            order.AddCustomerDetail(command.CustomerDetail);
            order.AddOrderLineItems(command.OrderLines);
            using (IUnitOfWork uow = this.CreateUnitOfWork <OrderAggregate>())
            {
                IOrderRepository repository = IoC.Container.Resolve <IOrderRepository>(uow);
                repository.Add(order);
                uow.Commit();
                order.AddEvent(new OnOrderCreated(order.Id));
            }
            order.PublishEvents();
        }