Skip to content

Instantly share code, notes, and snippets.

@MarcoNicolodi
Created November 29, 2019 16:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MarcoNicolodi/e7edf607771764e65c8d8af3a6920845 to your computer and use it in GitHub Desktop.
Save MarcoNicolodi/e7edf607771764e65c8d8af3a6920845 to your computer and use it in GitHub Desktop.
Proposal aggregate pseudo code showing its integrity with comments
public class Proposal
{
private List<Comments> _comments;
public IReadOnlyList<Comments> Comments => _comments.AsReadOnly();
private bool IsOpenForDiscussion => Status != ProposalStatus.Pending;
public void Discuss(Guid userId, string content)
{
if(!IsOpenForDiscussion)
throw new DomainException("Can't discuss about an closed proposal");
_comments.Add(new Comment(userId, Id, content));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment