Пример #1
0
        public override void Handle(CreateSalesOrderCommand command)
        {
            var order = new SalesOrder();

            order.Create(command.Id, command.MaxValue);

            IEnumerable <Event> events = order.GetUncommittedEvents();

            _salesOrderRepository.Save(order);

            order.AcceptUncommittedEvents();

            _eventBus.Publish(events);
        }
Пример #2
0
        public void Handle(CreateSalesOrderCommand command)
        {
            var repository = _container.Resolve <IRepository <SalesOrder> >();

            try
            {
                var order = new SalesOrder();
                order.Create(command.Id, command.MaxValue);
                IEnumerable <Event> events = order.GetUncommittedEvents();
                repository.Save(order);
                order.AcceptUncommittedEvents();
                _eventBus.Send(events);
            }
            finally
            {
                _container.Release(repository);
            }
        }