Exemple #1
0
        public async Task <IActionResult> CreateOrderAsync()
        {
            var random = new Random();
            var items  = new List <OrderItemDTO>();
            var count  = random.Next(2, 5);

            for (int i = 0; i < count; ++i)
            {
                var product = Guid.NewGuid();
                items.Add(new OrderItemDTO
                {
                    ProductName = "product" + product.ToString("N"),
                    ProductId   = product,
                    Units       = random.Next(1, 10),
                    Discount    = 0,
                    UnitPrice   = random.Next(2, 1000)
                });
            }

            await _orderingAppService.CreateOrder(new CreateOrderDTO(items,
                                                                     "HELLO",
                                                                     "上海", "张扬路500号", "上海", "中国", "200000", "what?"));

            return(Ok(true));
        }
Exemple #2
0
 public async Task Handle(UserCheckoutAcceptedEvent @event)
 {
     var dto = new CreateOrderDTO(@event.OrderItems, @event.UserId, @event.City, @event.Street,
                                  @event.State, @event.Country, @event.ZipCode, @event.Description);
     // IdentifiedCommand<> 必须保证只执行一次
     await _commandBus.CreateOrder(dto);
 }