Last active
August 21, 2018 17:54
-
-
Save arleypadua/5675987e7f497f4d9396f8f495a53b8c to your computer and use it in GitHub Desktop.
anemic-domain-model-encapsulated-constructor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static Order New(string orderId, string customerId, DateTime? creationTime = null) | |
{ | |
if (string.IsNullOrWhiteSpace(orderId)) throw new ArgumentNullException(nameof(orderId)); | |
if (string.IsNullOrWhiteSpace(customerId)) throw new ArgumentNullException(nameof(customerId)); | |
return new Order | |
{ | |
OrderId = orderId, | |
CustomerId = customerId, | |
CreationTime = creationTime ?? DateTime.UtcNow, | |
Items = new List<OrderItem>() | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment