Skip to content

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.
Namespace SampleApi
Assembly SampleApi
Package v1.0.0.0
public class Customer
A 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.
DateTimeOffset
DateTimeOffset Customer.CreatedAt

Gets or sets the UTC date and time when this customer record was created.

Automatically set to UtcNow at construction. This value should not be modified after the initial persistence operation.
Email Section titled Email nullable
string?
string? Customer.Email

Gets or sets the customer's email address, used for account verification and transactional notifications.

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.
string Customer.FullName

Gets or sets the customer's full display name.

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 Customer.Id

Gets or sets the globally unique identifier for this customer.

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.
bool Customer.IsActive

Gets or sets a value indicating whether the customer account is currently active.

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.
ContactMethod Customer.PreferredContact

Gets or sets the customer's preferred communication channel.

Defaults to Email. When sending notifications, the system should honour this preference and fall back to email only when the preferred channel is unavailable.
List<string>
List<string> Customer.Tags

Gets or sets the list of free-form tags used for customer segmentation and targeted marketing campaigns.

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.

Adding a segmentation tag to an existing customer:

customer.Tags.Add("loyalty-program");

Creating 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
};