// Factory method for creation public static Initiative Create( string title, string description, int ownerPersonId, int?businessContactId = null, bool skipEmailNotification = false ) { Ensure.String.IsNotNullOrWhiteSpace(title, nameof(title)); Ensure.String.IsNotNullOrWhiteSpace(description, nameof(description)); Ensure.Comparable.IsGt(ownerPersonId, 0, nameof(ownerPersonId)); var initiative = new Initiative(Guid.NewGuid()) { Title = title, Description = description, Stakeholders = new List <Stakeholder>() { Stakeholder.Create(ownerPersonId, StakeholderType.Requestor) } }; if (businessContactId.HasValue && businessContactId.Value != ownerPersonId) { initiative.Stakeholders.Add(Stakeholder.Create(businessContactId.Value, StakeholderType.BusinessContact)); } initiative.StatusHistories = new HashSet <InitiativeStatusHistory>(); initiative.CreatedDate = DateTime.UtcNow; initiative.AddDomainEvent(new InitiativeCreatedDomainEvent(initiative.Uid, ownerPersonId, skipEmailNotification)); return(initiative); }
public void AddStakeholder(int userId, StakeholderType type) { Stakeholders.Add(Stakeholder.Create(userId, type)); // raise domain event AddDomainEvent(new StakeholderAddedDomainEvent(Uid, userId, type)); }