Skip to content

Instantly share code, notes, and snippets.

@dcomartin
Created November 16, 2022 23:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcomartin/ffbb9e656902f53721f357e2d4773a45 to your computer and use it in GitHub Desktop.
Save dcomartin/ffbb9e656902f53721f357e2d4773a45 to your computer and use it in GitHub Desktop.
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