Skip to content

Commit

Permalink
Fixed Canceling ShoppingCart in Marten ECommerce example
Browse files Browse the repository at this point in the history
  • Loading branch information
oskardudycz committed Mar 12, 2022
1 parent 5321949 commit 89614f9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
Expand Up @@ -36,7 +36,10 @@ public async Task Invoke(HttpContext context /* other scoped dependencies */)
private Task HandleExceptionAsync(HttpContext context, Exception exception)
{
logger.LogError(exception, exception.Message);
Console.WriteLine(exception.Message);
Console.WriteLine("ERROR:" + exception.Message + exception.StackTrace);

if(exception.InnerException != null)
Console.WriteLine("INNER DETAILS:" + exception.InnerException.Message + exception.InnerException.StackTrace);

var codeInfo = ExceptionToHttpStatusMapper.Map(exception);

Expand Down Expand Up @@ -70,4 +73,4 @@ public static class ExceptionHandlingMiddlewareExtensions
ExceptionToHttpStatusMapper.CustomMap = customMap;
return app.UseMiddleware<ExceptionHandlingMiddleware>();
}
}
}
Expand Up @@ -38,7 +38,7 @@ public async Task<Unit> Handle(CancelShoppingCart command, CancellationToken can
await scope.Do((expectedVersion, traceMetadata) =>
cartRepository.GetAndUpdate(
command.CartId,
cart => cart.Confirm(),
cart => cart.Cancel(),
expectedVersion,
traceMetadata,
cancellationToken
Expand Down
1 change: 1 addition & 0 deletions Sample/ECommerce/Carts/Carts/ShoppingCarts/ShoppingCart.cs
Expand Up @@ -49,6 +49,7 @@ public void Apply(ShoppingCartOpened @event)
Id = @event.CartId;
ClientId = @event.ClientId;
ProductItems = new List<PricedProductItem>();
Status = ShoppingCartStatus.Pending;
}

public void AddProduct(
Expand Down

0 comments on commit 89614f9

Please sign in to comment.