Skip to content

Commit

Permalink
feat: Add virtual creation method in CustomerOrderAggregateRepository
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeyshibanov committed Aug 21, 2024
1 parent e035294 commit dc64890
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ public async Task<CustomerOrderAggregate> GetOrderByIdAsync(string orderId)
var order = await _customerOrderService.GetByIdAsync(orderId);
if (order != null)
{
var result = await InnerGetCustomerOrderAggregatesFromCustomerOrdersAsync(new[] { order });
var result = await InnerGetCustomerOrderAggregatesFromCustomerOrdersAsync([order]);
return result.FirstOrDefault();
}
return null;
}

public async Task<CustomerOrderAggregate> CreateOrderFromCart(ShoppingCart cart)
public virtual async Task<CustomerOrderAggregate> CreateOrderFromCart(ShoppingCart cart)
{
var order = await _customerOrderBuilder.PlaceCustomerOrderFromCartAsync(cart);
var aggregates = await InnerGetCustomerOrderAggregatesFromCustomerOrdersAsync([order], order.LanguageCode);
Expand All @@ -52,7 +52,7 @@ public async Task<CustomerOrderAggregate> CreateOrderFromCart(ShoppingCart cart)

public async Task<CustomerOrderAggregate> GetAggregateFromOrderAsync(CustomerOrder order)
{
var result = await InnerGetCustomerOrderAggregatesFromCustomerOrdersAsync(new[] { order });
var result = await InnerGetCustomerOrderAggregatesFromCustomerOrdersAsync([order]);
return result.FirstOrDefault();
}

Expand All @@ -68,7 +68,7 @@ protected virtual async Task<IList<CustomerOrderAggregate>> InnerGetCustomerOrde
return orders.Select(x =>
{
var aggregate = _customerOrderAggregateFactory();
aggregate.GrabCustomerOrder(x.Clone() as CustomerOrder, currencies.GetCurrencyForLanguage(x.Currency, cultureName ?? x.LanguageCode));
aggregate.GrabCustomerOrder(x.CloneTyped(), currencies.GetCurrencyForLanguage(x.Currency, cultureName ?? x.LanguageCode));
return aggregate;
}).ToList();
}
Expand Down

0 comments on commit dc64890

Please sign in to comment.