Skip to content

Commit

Permalink
Fix quantities
Browse files Browse the repository at this point in the history
  • Loading branch information
fredimachado committed May 25, 2024
1 parent 0643dbe commit 1ff2cd7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/Cashier/NCafe.Cashier.Domain/Commands/PlaceOrder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
2 changes: 1 addition & 1 deletion src/UI/NCafe.Web/Pages/Cashier/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1ff2cd7

Please sign in to comment.