Skip to content

Instantly share code, notes, and snippets.

@MarcoNicolodi
Last active October 13, 2019 20:13
Show Gist options
  • Save MarcoNicolodi/5d8f0b0d7487076cf4a0bcf9e432090a to your computer and use it in GitHub Desktop.
Save MarcoNicolodi/5d8f0b0d7487076cf4a0bcf9e432090a to your computer and use it in GitHub Desktop.
Proposal aggregate root relationship with Comment entity
public class Proposal
{
private List<Comments> _comments;
public ReadOnlyList<Comments> Comments => _comments.AsReadOnly();
public void Discuss(Guid userId, string content)
{
if(Status != ProposalStatus.Pending)
throw new DomainException("Can't discuss about an closed proposal");
_comments.Add(new Comment(Id, userId, content));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment