Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            // Setting-up the bus
            OrderView orderView = new OrderView();
            var       bus       = SetupBus(orderView);

            // Sending commands
            var id1 = Guid.NewGuid();

            bus.SendAndWait(new CreateOrder(id1));
            bus.SendAndWait(new AddOrderLine(id1, new OrderLine(5, "My Product")));
            bus.SendAndWait(new AddOrderLine(id1, new OrderLine(10, "My Other Product")));
            bus.SendAndWait(new CompleteOrder(id1));

            #region Other example

            //var id2 = Guid.NewGuid();
            //bus.SendAndWait(new CreateOrder(id2));
            //bus.SendAndWait(new AddOrderLine(id2, new OrderLine(1, "My Last Product")));

            #endregion

            // Displaying the view
            foreach (var orderDto in orderView.GetAll())
            {
                Console.WriteLine(orderDto);
            }
        }
Ejemplo n.º 2
0
            public void Test()
            {
                OrderView orderView = new OrderView();
                var       handler   = new OrderEventHandler(orderView);

                handler.Handle(new OrderCreated(1.MakeGuid()));
                handler.Handle(new OrderLineAdded(1.MakeGuid(), new OrderLine(3, "MyProduct")));

                var view = new OrderView();

                view.GetAll().Single().ShouldBeEquivalentTo(new OrderDto()
                {
                    Id         = 1.MakeGuid(),
                    OrderLines = new []
                    {
                        new OrderLineDto()
                        {
                            Quantity    = 3,
                            ProductName = "MyProduct"
                        }
                    }
                });
            }
Ejemplo n.º 3
0
        public ActionResult Get()
        {
            var result = view.GetAll();

            return(Ok(result));
        }