public async Task UpdateStockByOrder(Order order) { foreach (var item in order.Items) { var stockItem = await _stockRepository.GetByIdAsync(item.ProductId, _context.Transaction); stockItem.Quantity = stockItem.Quantity - item.Quantity; await _stockRepository.UpdateAsync(stockItem, _context.Transaction); } }