Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,17 @@ public void SetPayment(Payment payment)

public async Task<Order.Order> PlaceOrder(IOrderRepository orderRepository)
{
var limitedProducts = Products.Where(x => x.Product.LimitedAvailability);

/*
* This is obviously a naive implementation but in same cases might yield better results
* than using JOINs, since we can issue simpler queries in parallel and then
* scatter and collect with Task.WhenAll(...)
*/
foreach (var product in Products)
foreach (var limitedProduct in limitedProducts)
{
var orderWithLimitedProductExistsInThisQuarter = await orderRepository.Exists(
specification: new ActiveOrderWithLimitedProductThisQuarter(CustomerId, product.Product.Name),
specification: new ActiveOrderWithLimitedProductThisQuarter(CustomerId, limitedProduct.Product.Name),
cancellationToken: CancellationToken.None);

if (orderWithLimitedProductExistsInThisQuarter)
Expand Down