public override AddOrderCommand Handle(AddOrderCommand addOrderCommand)
        {
            using (var scope = _ordersDao.BeginTransaction())
            {
                base.logger.DebugFormat(string.Format("Writing new order for customer: {0}", addOrderCommand.CustomerName));
                var inserted = _ordersDao.Add(
                    new Order(
                        customerName: addOrderCommand.CustomerName,
                        orderDescription: addOrderCommand.OrderDescription,
                        dueDate: addOrderCommand.OrderDueDate
                        )
                    );

                scope.Commit();

                addOrderCommand.OrderId = inserted.Id;
            }

            _commandProcessor.Publish(
                new OrderAddedEvent(
                    addOrderCommand.CustomerName,
                    addOrderCommand.OrderDescription,
                    addOrderCommand.OrderDueDate));

            return(base.Handle(addOrderCommand));
        }
예제 #2
0
        public override AddOrderCommand Handle(AddOrderCommand addOrderCommand)
        {
            using (var scope = _ordersDao.BeginTransaction())
            {
                var inserted = _ordersDao.Add(
                    new Order(
                        customerName: addOrderCommand.OrderName,
                        orderDescription: addOrderCommand.OrderDescription,
                        dueDate: addOrderCommand.OrderDueDate
                        )
                    );

                scope.Commit();

                addOrderCommand.OrderId = inserted.Id;
            }

            return(base.Handle(addOrderCommand));
        }