diff --git a/src/Cashier/NCafe.Cashier.Domain/Commands/PlaceOrder.cs b/src/Cashier/NCafe.Cashier.Domain/Commands/PlaceOrder.cs index d2f84ed..f25addf 100644 --- a/src/Cashier/NCafe.Cashier.Domain/Commands/PlaceOrder.cs +++ b/src/Cashier/NCafe.Cashier.Domain/Commands/PlaceOrder.cs @@ -28,6 +28,9 @@ public async Task Handle(PlaceOrder command, CancellationToken cancellationToken await _repository.Save(order); await _publisher.Publish( - new OrderPlacedMessage(order.Id, order.Items.Select(x => (Messages.OrderItem)x).ToArray(), order.Customer)); + new OrderPlacedMessage( + order.Id, + order.Items.GroupBy(i => i.ProductId).Select(i => new Messages.OrderItem(i.First().ProductId, i.First().Name, i.Sum(x => x.Quantity), i.First().Price)).ToArray(), + order.Customer)); } } diff --git a/src/UI/NCafe.Web/Pages/Cashier/Index.razor b/src/UI/NCafe.Web/Pages/Cashier/Index.razor index b5414c0..c901874 100644 --- a/src/UI/NCafe.Web/Pages/Cashier/Index.razor +++ b/src/UI/NCafe.Web/Pages/Cashier/Index.razor @@ -112,7 +112,7 @@ { var response = await Http.PostAsJsonAsync( $"{_baseAddress}/orders/add-item", - new { OrderId = _order.Id, item.ProductId, item.Quantity }); + new { OrderId = _order.Id, item.ProductId, Quantity = 1 }); response.EnsureSuccessStatusCode(); } catch (Exception ex)