Class BuyerIdentifier
Value object representing a buyer identifier. A buyer is either an existing customer or a registered member. This type guarantees that only one kind can be set at a time.
public sealed record BuyerIdentifier
- Inheritance
-
objectBuyerIdentifier
- Extension Methods
Properties
Kind
The kind of this buyer identifier (Customer or Member).
public BuyerIdentifierKind Kind { get; }
Property Value
Value
The numeric value of the identifier.
public int Value { get; }
Property Value
- int
Methods
Equals(BuyerIdentifier?)
public bool Equals(BuyerIdentifier? other)
Parameters
otherBuyerIdentifier
Returns
- bool
Equals(object?)
public override bool Equals(object? obj)
Parameters
objobject
Returns
- bool
FromCustomerId(int)
Creates a buyer identifier for an existing customer. Corresponds to Customer.
public static BuyerIdentifier FromCustomerId(int customerId)
Parameters
customerIdintThe customer identifier.
Returns
- BuyerIdentifier
A BuyerIdentifier of kind Customer when customerId > 0; otherwise
null.
FromMemberId(int)
Creates a buyer identifier for a registered member. Corresponds to Member.
public static BuyerIdentifier FromMemberId(int memberId)
Parameters
memberIdintThe member identifier.
Returns
- BuyerIdentifier
A BuyerIdentifier of kind Member when memberId > 0; otherwise
null.
Remarks
If the registered member ID corresponds to an existing customer, then in contexts such as order creation or price calculations, this BuyerIdentifier is used to identify the customer, regardless of whether it was created using FromCustomerId(int) or FromMemberId(int).
GetHashCode()
public override int GetHashCode()
Returns
- int
ToString()
public override string ToString()
Returns
- string
Operators
operator ==(BuyerIdentifier?, BuyerIdentifier?)
public static bool operator ==(BuyerIdentifier? left, BuyerIdentifier? right)
Parameters
leftBuyerIdentifierrightBuyerIdentifier
Returns
- bool
operator !=(BuyerIdentifier?, BuyerIdentifier?)
public static bool operator !=(BuyerIdentifier? left, BuyerIdentifier? right)
Parameters
leftBuyerIdentifierrightBuyerIdentifier
Returns
- bool