public void Handle(SubmitOrderRequest message)
        {
            var order = new Order
            {
                Id       = message.Id,
                Quantity = message.Quantity,
                Status   = OrderStatus.Pending
            };

            // Thread.Sleep(4000); //simulate processing

            bus.Reply(new SubmitOrderResponse {
                Order = order
            });
        }
Пример #2
0
        public void Handle(SubmitOrderRequest message)
        {
            var order = new Order
            {
                Id       = message.Id,
                Quantity = message.Quantity,
                Status   = OrderStatus.Pending
            };

            // Thread.Sleep(4000); //simulate processing

            var response = bus.CreateInstance <SubmitOrderResponse>(x => x.Order = order);

            bus.Reply(response);
        }
Пример #3
0
        public void Handle(OrderMessage message)
        {
            //simulate processing
            Thread.Sleep(4000);

            //simulate business logic
            var order = new Order
            {
                Id       = message.Id,
                Quantity = message.Quantity,
                Status   = message.Quantity < 100 ? OrderStatus.Approved : OrderStatus.AwaitingApproval
            };

            //store the order in "the database"
            Orders.AddOrder(order);

            //publish update
            Bus.Publish <OrderUpdatedEvent>(x => x.UpdatedOrder = order);
        }
Пример #4
0
        public void Handle(OrderMessage message)
        {
            var order = new Order
            {
                Id       = message.Id,
                Quantity = message.Quantity
            };

            //simulate processing
            Thread.Sleep(4000);

            //simlute business logic
            order.Status = message.Quantity < 100 ? OrderStatus.Approved : OrderStatus.AwaitingApproval;

            orders.AddOrder(order);

            //publish update
            var orderUpdatedEvent = bus.CreateInstance <OrderUpdatedEvent>(x => x.UpdatedOrder = order);

            bus.Publish(orderUpdatedEvent);
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            var order = new Order
                            {
                                Id = Guid.NewGuid(),
                                Quantity = Convert.ToInt32(txtQuatity.Text),
                                Status = OrderStatus.Pending

                            };

            Global.Bus.Send(new OrderMessage
                                {
                                    Id = order.Id,
                                    Quantity = order.Quantity
                                });

            lock(Global.Orders)
                Global.Orders.Add(order);

            Refresh();
        }
Пример #6
0
 public bool Equals(Order other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return other.Id.Equals(Id);
 }