public async Task Handle(Catalog.Product.Events.DescriptionUpdated e, IMessageHandlerContext ctx) { var basketIds = await ctx.Service <Basket.Services.BasketsUsingProduct, Guid[]>(x => { x.ProductId = e.ProductId; }) .ConfigureAwait(false); // Update the description for all baskets foreach (var id in basketIds) { var item = await ctx.UoW().Get <Models.BasketItemIndex>(ItemIdGenerator(id, e.ProductId)).ConfigureAwait(false); item.ProductDescription = e.Description; await ctx.UoW().Update(ItemIdGenerator(id, e.ProductId), item).ConfigureAwait(false); } }
public async Task Handle(Catalog.Product.Events.DescriptionUpdated e, IMessageHandlerContext ctx) { var basketIds = await ctx.Service <Services.BasketsUsingProduct, Guid[]>(x => { x.ProductId = e.ProductId; }) .ConfigureAwait(false); // Update the subtotal and quantity for all baskets foreach (var id in basketIds) { var basket = await ctx.UoW().Get <Models.Basket>(id) .ConfigureAwait(false); var item = basket.Items.Single(x => x.ProductId == e.ProductId); item.ProductDescription = e.Description; await ctx.UoW().Update(id, basket).ConfigureAwait(false); } }