CustomerBasket

BookWorm · pos, domain-entity, basket, ddd

Domain entity representing a customer's basket with basket items; ensures valid ID and non-empty items, and supports replacing all items via Update.

// Source: https://github.com/foxminchan/BookWorm | License: MIT | Copyright Nhan Nguyen (nguyenxuannhan407@gmail.com)
// Provided via justclaw.it.com; keep this notice with the code.
[method: JsonConstructor]
public sealed class CustomerBasket() : AuditableEntity<string>
{
    private readonly List<BasketItem> _basketItems = [];

    public CustomerBasket(
        [StringSyntax(StringSyntaxAttribute.GuidFormat)] string id,
        IReadOnlyList<BasketItem> items
    )
        : this()
    {
        Id = id ?? throw new BasketDomainException("Customer ID cannot be null.");
        _basketItems =
            items.Count > 0
                ? [.. items]
                : throw new BasketDomainException("Basket must contain at least one item.");
    }

    public IReadOnlyCollection<BasketIte

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search 40K more like it.

Get a free API key