public void AddLink(Guid linkedId, LinkedParticipantType linkType) { var existingLink = LinkedParticipants.SingleOrDefault(x => x.LinkedId == linkedId && x.Type == linkType); if (existingLink != null) { throw new DomainRuleException("LinkedParticipant", "Participant is already linked with the same link type"); } LinkedParticipants.Add(new LinkedParticipant(Id, linkedId, linkType)); }
public void RemoveLink(LinkedParticipant linkedParticipant) { var link = LinkedParticipants.SingleOrDefault( x => x.LinkedId == linkedParticipant.LinkedId && x.Type == linkedParticipant.Type); if (link == null) { throw new DomainRuleException("LinkedParticipant", "Link does not exist"); } LinkedParticipants.Remove(linkedParticipant); }
public void RemoveAllLinks() { LinkedParticipants.Clear(); }