Customer
Class public
Represents a customer entity in the system, serving as the primary domain model for all customer-related operations including creation, retrieval, and segmentation.
Definition
Section titled Definitionpublic class CustomerRemarks
Section titled RemarksA Customer is the aggregate root for customer data. Every customer is assigned a globally unique
Id at creation time and must have a non-empty FullName. Customers are active by default and can be deactivated through Guid). Tags enable flexible segmentation—for example, marking customers as "vip", "wholesale", or "beta-tester"—without requiring schema changes. The PreferredContact property controls which channel is used for outbound communications.Properties7
Section titled PropertiesCreatedAt Section titled CreatedAt DateTimeOffset DateTimeOffset Customer.CreatedAtGets or sets the UTC date and time when this customer record was created.
Remarks
Automatically set to
UtcNow at construction. This value should not be modified after the initial persistence operation.string? string? Customer.EmailGets or sets the customer's email address, used for account verification and transactional notifications.
Remarks
When
null, the customer has not provided an email and cannot receive email-based communications. Validation should enforce RFC 5322 format when a value is present.FullName Section titled FullName string string Customer.FullNameGets or sets the customer's full display name.
Remarks
This property is required and must not be
null or whitespace. It is used throughout the UI and in transactional emails as the primary way to address the customer.Guid Guid Customer.IdGets or sets the globally unique identifier for this customer.
Remarks
This value is typically generated by the caller at construction time using
NewGuid. It serves as the primary key across all persistence layers and is immutable after creation.IsActive Section titled IsActive bool bool Customer.IsActiveGets or sets a value indicating whether the customer account is currently active.
Remarks
Inactive customers are excluded from search results and cannot place new orders. Use
Guid) to set this to false in a controlled manner that also raises the appropriate domain events.PreferredContact Section titled PreferredContact ContactMethod Customer.PreferredContactGets or sets the customer's preferred communication channel.
Remarks
Defaults to
Email. When sending notifications, the system should honour this preference and fall back to email only when the preferred channel is unavailable.Tags Section titled Tags List<string> List<string> Customer.TagsGets or sets the list of free-form tags used for customer segmentation and targeted marketing campaigns.
Remarks
Tags are case-insensitive string labels. Common conventions include lowercase kebab-case (e.g., "early-adopter", "high-value"). An empty list indicates that no segmentation has been applied.
Examples
Adding a segmentation tag to an existing customer:
customer.Tags.Add("loyalty-program");Examples
Section titled ExamplesCreating a new customer with required properties:
var customer = new Customer{ Id = Guid.NewGuid(), FullName = "Jane Doe", Email = "jane.doe@example.com", Tags = ["vip", "early-adopter"], PreferredContact = ContactMethod.Email};