コード例 #1
0
        public async Task UpdatePricesForIntegrationEvent(Models.PriceUpdate priceUpdate)
        {
            await using (var shoppingBasketDbContext = new ShoppingBasketDbContext(dbContextOptions))
            {
                var basketLinesToUpdate = shoppingBasketDbContext.BasketLines.Where(x => x.EventId == priceUpdate.EventId);

                await basketLinesToUpdate.ForEachAsync((basketLineToUpdate) =>
                                                       basketLineToUpdate.Price = priceUpdate.Price
                                                       );

                await shoppingBasketDbContext.SaveChangesAsync();
            }
        }
コード例 #2
0
        public async Task UpdatePricesForIntegrationEvent(Models.PriceUpdate priceUpdate)
        {
            var basketLinesToUpdate = shoppingBasketDbContext.BasketLines.Where(x => x.EventId == priceUpdate.EventId);

            await basketLinesToUpdate.ForEachAsync((basketLineToUpdate) =>
                                                   basketLineToUpdate.Price = priceUpdate.Price
                                                   );

            //foreach (var basketLineToUpdate in basketLinesToUpdate)
            //{
            //    basketLineToUpdate.Price = priceUpdate.Price;
            //}
            await SaveChanges();
        }