Skip to content

Instantly share code, notes, and snippets.

@dcomartin
Created Nov 16, 2022
Embed
What would you like to do?
public class Basket : BaseEntity, IAggregateRoot
{
private readonly List<BasketItem> _items = new List<BasketItem>();
public string BuyerId { get; private set; }
public IReadOnlyCollection<BasketItem> Items => _items.AsReadOnly();
public int TotalItems => _items.Sum(i => i.Quantity);
public Basket(string buyerId)
{
BuyerId = buyerId;
}
// Rest of the code omitted
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment