public Customer CreateCustomer(String name, Money creditLimit) { Customer customer; using (var scope = new TransactionScope()) { ResultsWithEvents customerWithEvents = Create(name, creditLimit); customer = customerRepository.InsertCustomer(customerWithEvents.Customer); domainEventPublisher.Publish(typeof(Customer).Name, customer.Id, customerWithEvents.Events); scope.Complete(); return(customer); } }
public Order CreateOrder(OrderDetails orderDetails) { Order order; using (var scope = new TransactionScope()) { ResultsWithEvents orderWithEvents = Create(orderDetails); order = orderRepository.Add(orderWithEvents.Order); domainEventPublisher.Publish(typeof(Order).Name, order.Id, orderWithEvents.Events); scope.Complete(); return(order); } }