Пример #1
0
        public MyModule()
        {
            Get["/orders"] = _ =>
            {
                return "hello";
            };
            Get["/orders/{orderid}"] = _ =>
            {
                var order = new Order()
                {
                    OrderId = 897,
                    CustomerId = 123,
                    Details = new List<OrderDetail>()
                    {
                        new OrderDetail()
                        {
                            ProductId = 555,
                            Quantity = 2
                        },
                        new OrderDetail()
                        {
                            ProductId = 222,
                            Quantity = 987
                        }
                    }
                };

                return Response.AsJson(order);
            };
        }
Пример #2
0
        public void DeleteOrder(Order order)
        {
            try
              {
            IOC.RegisterComponents();
            Order localOrder = Repository<Order>.Get(order.OrderId, Common.Util.GetContextId());
            if (localOrder == null)
            {
              localOrder = Repository<Order>.Where(x => x.OrderId == order.OrderId,Common.Util.GetContextId()).FirstOrDefault();
            }

            if (localOrder != null)
            {
              var orderDetails = Repository<OrderDetail>.Where(x => x.ParentOrder.OrderId == order.OrderId, Common.Util.GetContextId());
              foreach (OrderDetail det in orderDetails)
              {
            Repository<OrderDetail>.Remove(det, Common.Util.GetContextId());
              }
            }

            Repository<Order>.Remove(localOrder, Common.Util.GetContextId());

            new Thread(()=> NotifySubscribers("Delete", order)).Start();
              }
              catch (Exception ex)
              {
            throw new FaultException(ex.Message);
              }
        }
Пример #3
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     OrderService.Order order = orderBindingSource.Current as OrderService.Order;
     if (order == null)
     {
         MessageBox.Show("请选择一个订单");
         return;
     }
     orderService.RemoveOrder(order.OrderId);
     orderBindingSource.DataSource = orderService.Orders;
     orderBindingSource.ResetBindings(false);
 }
        public void TestAddOrderUsingService()
        {
            Order order1 = new Order();
              Order order2 = new Order();
              Order order3 = new Order();

              AddOrderCommand addCommand1 = new AddOrderCommand(order1);
              AddOrderCommand addCommand2 = new AddOrderCommand(order2);
              AddOrderCommand addCommand3 = new AddOrderCommand(order3);

              CommanndServiceReference.CommandServiceClient service = new OrderProcessing.Tests.CommanndServiceReference.CommandServiceClient();
              AssignContextId(service.InnerChannel);
              addCommand1 = (AddOrderCommand)service.ExecuteCommand(addCommand1);
              addCommand2 = (AddOrderCommand)service.ExecuteCommand(addCommand2);
              addCommand3 = (AddOrderCommand)service.ExecuteCommand(addCommand3);

              ICommand command = (ICommand)service.Undo();
              Order deletedOrder = command.CommandParams[0] as Order;
              Assert.That(((Order)addCommand3.CommandParams[0]).OrderId, Is.EqualTo(deletedOrder.OrderId));
        }
        public void TestAddOrder()
        {
            Order order1 = new Order();
              Order order2 = new Order();
              Order order3 = new Order();

              AddOrderCommand addCommand1 = new AddOrderCommand(order1);
              AddOrderCommand addCommand2 = new AddOrderCommand(order2);
              AddOrderCommand addCommand3 = new AddOrderCommand(order3);

              CommandService service = new CommandService();

              service.ExecuteCommand(addCommand1);
              service.ExecuteCommand(addCommand2);
              service.ExecuteCommand(addCommand3);

              ICommand command = service.Undo();
              Order deletedOrder = command.CommandParams[0] as Order;
              Assert.That(order3.OrderId,Is.EqualTo(deletedOrder.OrderId));

              Repositiory.Close(Common.Util.GetContextId());
        }
Пример #6
0
 public void SubmitOrder(Order order)
 {
     Console.WriteLine(string.Format("process order {0} for customer {1}", order.OrderId, order.CustomerName));
 }
Пример #7
0
 public void AddOrder(Order order)
 {
     Repository<Order>.Save(order, Common.Util.GetContextId());
       new Thread(()=> NotifySubscribers("Add", order)).Start();
 }
Пример #8
0
        void NotifySubscribers(string action, Order order)
        {
            if (action == "Add")
              {
            foreach (IOrderServiceCallback client in _subscriberList)
            {
              new Thread(() =>
              {
            try
            {
              client.OrderAdded(order);
            }
            catch (Exception ex)
            {
              Console.WriteLine(ex.Message);
            }
              }).Start();
            }
              }

              if (action == "Delete")
              {
            foreach (IOrderServiceCallback client in _subscriberList)
            {
              try
              {
            client.OrderRemoved(order);
              }
              catch (Exception ex)
              {
            Console.WriteLine(ex.Message);
              }
              //new Thread(() =>
              //{
              //  try
              //  {
              //    client.OrderRemoved(order);
              //  }
              //  catch (Exception ex)
              //  {
              //    Console.WriteLine(ex.Message);
              //  }
              //}).Start();
            }
              }
        }
Пример #9
0
 public void UpdateOrder(Order order)
 {
     throw new NotImplementedException();
 }
 public AddOrderCommand(Order order)
 {
     _order = order;
 }
Пример #11
0
 public void SpecifyOrder(Order order)
 {
     order.Specify(First<GridInterceptingMessageHandler>
       .Then<SagaMessageHandler>());
 }
 public void Test_DeleteOrderAndOrderDetailsCascaded()
 {
     OrderService.OrderService ordService = new OrderService.OrderService();
       Order o = new Order() { OrderId=10263};
       ordService.DeleteOrder(o);
 }