minor code rearange, quantity as optional parameter, removed some unused fields
This commit is contained in:
@@ -33,11 +33,11 @@ namespace Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate
|
||||
// but only through the method Order.AddOrderItem() which includes behavior.
|
||||
private readonly List<OrderItem> _orderItems = new List<OrderItem>();
|
||||
|
||||
public IReadOnlyCollection<OrderItem> OrderItems => _orderItems.AsReadOnly();
|
||||
// Using List<>.AsReadOnly()
|
||||
// This will create a read only wrapper around the private list so is protected against "external updates".
|
||||
// It's much cheaper than .ToList() because it will not have to copy all items in a new collection. (Just one heap alloc for the wrapper instance)
|
||||
//https://msdn.microsoft.com/en-us/library/e78dcd75(v=vs.110).aspx
|
||||
public IReadOnlyCollection<OrderItem> OrderItems => _orderItems.AsReadOnly();
|
||||
|
||||
public decimal Total()
|
||||
{
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Microsoft.eShopWeb.ApplicationCore.Interfaces
|
||||
{
|
||||
Task<int> GetBasketItemCountAsync(string userName);
|
||||
Task TransferBasketAsync(string anonymousId, string userName);
|
||||
Task AddItemToBasket(int basketId, int catalogItemId, decimal price, int quantity);
|
||||
Task AddItemToBasket(int basketId, int catalogItemId, decimal price, int quantity = 1);
|
||||
Task SetQuantities(int basketId, Dictionary<string, int> quantities);
|
||||
Task DeleteBasketAsync(int basketId);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Microsoft.eShopWeb.ApplicationCore.Services
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task AddItemToBasket(int basketId, int catalogItemId, decimal price, int quantity)
|
||||
public async Task AddItemToBasket(int basketId, int catalogItemId, decimal price, int quantity = 1)
|
||||
{
|
||||
var basket = await _basketRepository.GetByIdAsync(basketId);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user