/// <summary>
        ///     Creates a new instance.
        /// </summary>
        /// <param name="group">The group that owns the membership.</param>
        /// <param name="member">The group that the stakeholder belongs to.</param>
        public UserGroupMembership(UserGroup group, Stakeholder member)
        {
            Guard.ArgumentNotNull(group, nameof(group));
            Guard.ArgumentNotNull(member, nameof(member));

            if (group.ScenarioId != member.ScenarioId)
            {
                throw new InvalidOperationException("Group and member must belong to the same scenario.");
            }

            Id = SeqGuid.Create();

            ScenarioId       = group.ScenarioId;
            GroupId          = group.Id;
            MemberId         = member.Id;
            DateAdded        = DateTime.UtcNow;
            UserName         = "";
            DateLastModified = DateAdded;
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Creates a new instance.
        /// </summary>
        public StakeholderLogin(Stakeholder stakeholder, string externalId, string userName, string description = null, Scenario scenario = null)
        {
            Guard.ArgumentNotNullOrEmptyOrWhiteSpace(userName, nameof(userName));
            Guard.ArgumentNotNull(stakeholder, nameof(stakeholder));

            this.Id = SeqGuid.Create();

            this.UserName      = userName;
            this.ExternalId    = externalId ?? "";
            this.ScenarioId    = stakeholder.ScenarioId;
            this.StakeholderId = stakeholder.Id;
            this.Description   = description ?? "";
            this.DateAdded     = DateTime.UtcNow;
            this.LoginType     = "Windows";

            if (scenario != null)
            {
                ScenarioId = scenario.Id;
            }
        }