Skip to content

Commit

Permalink
GetCart should be async? (#372)
Browse files Browse the repository at this point in the history
Co-authored-by: Carter Socha <43380952+cartersocha@users.noreply.github.com>
  • Loading branch information
cartermp and cartersocha authored Sep 23, 2022
1 parent 86a0572 commit 0cbf181
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/cartservice/src/services/CartService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,16 @@ public async override Task<Empty> AddItem(AddItemRequest request, ServerCallCont
return Empty;
}

public override Task<Cart> GetCart(GetCartRequest request, ServerCallContext context)
public async override Task<Cart> GetCart(GetCartRequest request, ServerCallContext context)
{
var activity = Activity.Current;
activity?.SetTag("app.user.id", request.UserId);
activity?.AddEvent(new("Fetch cart"));

var cart = _cartStore.GetCartAsync(request.UserId);
var cart = await _cartStore.GetCartAsync(request.UserId);
var totalCart = 0;
foreach (CartItem item in cart.Result.Items) {
foreach (var item in cart.Items)
{
totalCart += item.Quantity;
}
activity?.SetTag("app.cart.items.count", totalCart);
Expand Down

0 comments on commit 0cbf181

Please sign in to comment.