Last active
June 23, 2018 20:56
-
-
Save ivanpaulovich/5d3f702a55a4700dd23a272a2dca5617 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 sealed class Customer : IEntity, IAggregateRoot | |
{ | |
public Guid Id { get; private set; } | |
public Name Name { get; private set; } | |
public SSN SSN { get; private set; } | |
public IReadOnlyCollection<Guid> Accounts | |
{ | |
get | |
{ | |
IReadOnlyCollection<Guid> readOnly = _accounts.GetAccountIds(); | |
return readOnly; | |
} | |
} | |
private AccountCollection _accounts; | |
public Customer(SSN ssn, Name name) | |
{ | |
Id = Guid.NewGuid(); | |
SSN = ssn; | |
Name = name; | |
_accounts = new AccountCollection(); | |
} | |
public void Register(Guid accountId) | |
{ | |
_accounts.Add(accountId); | |
} | |
private Customer() { } | |
public static Customer Load(Guid id, Name name, SSN ssn, AccountCollection accounts) | |
{ | |
Customer customer = new Customer(); | |
customer.Id = id; | |
customer.Name = name; | |
customer.SSN = ssn; | |
customer._accounts = accounts; | |
return customer; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment