static void Main(string[] args) { ChannelFactory<IOrderProcessor> channelFactory = new ChannelFactory<IOrderProcessor>("defaultEndpoint"); IOrderProcessor channel = channelFactory.CreateChannel(); Order order = new Order(Guid.NewGuid(), DateTime.Today, Guid.NewGuid(), "A Company"); order.OrderItems.Add(new OrderItem(Guid.NewGuid(), "PC", 5000, 20)); order.OrderItems.Add(new OrderItem(Guid.NewGuid(), "Printer", 7000, 2)); Console.WriteLine("Submit order to server"); using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required)) { channel.Submit(order); scope.Complete(); } Console.Read(); }
public static void Add(Order order) { _orderList.Add(order.OrderNo, order); }
public void Submit(Order order) { Orders.Add(order); Console.WriteLine("Receive an order."); Console.WriteLine(order.ToString()); }