コード例 #1
0
ファイル: UserState.cs プロジェクト: 573000126/wms-4
        public virtual void When(IUserStateCreated e)
        {
            ThrowOnWrongEvent(e);
            this.UserName = e.UserName;

            this.AccessFailedCount = (e.AccessFailedCount != null && e.AccessFailedCount.HasValue) ? e.AccessFailedCount.Value : default(int);

            this.Email = e.Email;

            this.EmailConfirmed = (e.EmailConfirmed != null && e.EmailConfirmed.HasValue) ? e.EmailConfirmed.Value : default(bool);

            this.LockoutEnabled = (e.LockoutEnabled != null && e.LockoutEnabled.HasValue) ? e.LockoutEnabled.Value : default(bool);

            this.LockoutEndDateUtc = e.LockoutEndDateUtc;

            this.PasswordHash = e.PasswordHash;

            this.PhoneNumber = e.PhoneNumber;

            this.PhoneNumberConfirmed = (e.PhoneNumberConfirmed != null && e.PhoneNumberConfirmed.HasValue) ? e.PhoneNumberConfirmed.Value : default(bool);

            this.TwoFactorEnabled = (e.TwoFactorEnabled != null && e.TwoFactorEnabled.HasValue) ? e.TwoFactorEnabled.Value : default(bool);

            this.SecurityStamp = e.SecurityStamp;

            this.Active = (e.Active != null && e.Active.HasValue) ? e.Active.Value : default(bool);

            this.Deleted = false;

            this.CreatedBy = e.CreatedBy;
            this.CreatedAt = e.CreatedAt;

            foreach (IUserRoleStateCreated innerEvent in e.UserRoleEvents)
            {
                IUserRoleState innerState = this.UserRoles.Get(innerEvent.GlobalId.RoleId);
                innerState.Mutate(innerEvent);
            }
            foreach (IUserClaimStateCreated innerEvent in e.UserClaimEvents)
            {
                IUserClaimState innerState = this.UserClaims.Get(innerEvent.GlobalId.ClaimId);
                innerState.Mutate(innerEvent);
            }
            foreach (IUserPermissionStateCreated innerEvent in e.UserPermissionEvents)
            {
                IUserPermissionState innerState = this.UserPermissions.Get(innerEvent.GlobalId.PermissionId);
                innerState.Mutate(innerEvent);
            }
            foreach (IUserLoginStateCreated innerEvent in e.UserLoginEvents)
            {
                IUserLoginState innerState = this.UserLogins.Get(innerEvent.GlobalId.LoginKey);
                innerState.Mutate(innerEvent);
            }
        }
コード例 #2
0
ファイル: UserState.cs プロジェクト: 573000126/wms-4
        public virtual void When(IUserStateMergePatched e)
        {
            ThrowOnWrongEvent(e);

            if (e.UserName == null)
            {
                if (e.IsPropertyUserNameRemoved)
                {
                    this.UserName = default(string);
                }
            }
            else
            {
                this.UserName = e.UserName;
            }

            if (e.AccessFailedCount == null)
            {
                if (e.IsPropertyAccessFailedCountRemoved)
                {
                    this.AccessFailedCount = default(int);
                }
            }
            else
            {
                this.AccessFailedCount = (e.AccessFailedCount != null && e.AccessFailedCount.HasValue) ? e.AccessFailedCount.Value : default(int);
            }

            if (e.Email == null)
            {
                if (e.IsPropertyEmailRemoved)
                {
                    this.Email = default(string);
                }
            }
            else
            {
                this.Email = e.Email;
            }

            if (e.EmailConfirmed == null)
            {
                if (e.IsPropertyEmailConfirmedRemoved)
                {
                    this.EmailConfirmed = default(bool);
                }
            }
            else
            {
                this.EmailConfirmed = (e.EmailConfirmed != null && e.EmailConfirmed.HasValue) ? e.EmailConfirmed.Value : default(bool);
            }

            if (e.LockoutEnabled == null)
            {
                if (e.IsPropertyLockoutEnabledRemoved)
                {
                    this.LockoutEnabled = default(bool);
                }
            }
            else
            {
                this.LockoutEnabled = (e.LockoutEnabled != null && e.LockoutEnabled.HasValue) ? e.LockoutEnabled.Value : default(bool);
            }

            if (e.LockoutEndDateUtc == null)
            {
                if (e.IsPropertyLockoutEndDateUtcRemoved)
                {
                    this.LockoutEndDateUtc = default(DateTime?);
                }
            }
            else
            {
                this.LockoutEndDateUtc = e.LockoutEndDateUtc;
            }

            if (e.PasswordHash == null)
            {
                if (e.IsPropertyPasswordHashRemoved)
                {
                    this.PasswordHash = default(string);
                }
            }
            else
            {
                this.PasswordHash = e.PasswordHash;
            }

            if (e.PhoneNumber == null)
            {
                if (e.IsPropertyPhoneNumberRemoved)
                {
                    this.PhoneNumber = default(string);
                }
            }
            else
            {
                this.PhoneNumber = e.PhoneNumber;
            }

            if (e.PhoneNumberConfirmed == null)
            {
                if (e.IsPropertyPhoneNumberConfirmedRemoved)
                {
                    this.PhoneNumberConfirmed = default(bool);
                }
            }
            else
            {
                this.PhoneNumberConfirmed = (e.PhoneNumberConfirmed != null && e.PhoneNumberConfirmed.HasValue) ? e.PhoneNumberConfirmed.Value : default(bool);
            }

            if (e.TwoFactorEnabled == null)
            {
                if (e.IsPropertyTwoFactorEnabledRemoved)
                {
                    this.TwoFactorEnabled = default(bool);
                }
            }
            else
            {
                this.TwoFactorEnabled = (e.TwoFactorEnabled != null && e.TwoFactorEnabled.HasValue) ? e.TwoFactorEnabled.Value : default(bool);
            }

            if (e.SecurityStamp == null)
            {
                if (e.IsPropertySecurityStampRemoved)
                {
                    this.SecurityStamp = default(string);
                }
            }
            else
            {
                this.SecurityStamp = e.SecurityStamp;
            }

            if (e.Active == null)
            {
                if (e.IsPropertyActiveRemoved)
                {
                    this.Active = default(bool);
                }
            }
            else
            {
                this.Active = (e.Active != null && e.Active.HasValue) ? e.Active.Value : default(bool);
            }


            this.UpdatedBy = e.CreatedBy;
            this.UpdatedAt = e.CreatedAt;


            foreach (IUserRoleStateEvent innerEvent in e.UserRoleEvents)
            {
                IUserRoleState innerState = this.UserRoles.Get(innerEvent.GlobalId.RoleId);

                innerState.Mutate(innerEvent);
                var removed = innerEvent as IUserRoleStateRemoved;
                if (removed != null)
                {
                    this.UserRoles.Remove(innerState);
                }
            }

            foreach (IUserClaimStateEvent innerEvent in e.UserClaimEvents)
            {
                IUserClaimState innerState = this.UserClaims.Get(innerEvent.GlobalId.ClaimId);

                innerState.Mutate(innerEvent);
                var removed = innerEvent as IUserClaimStateRemoved;
                if (removed != null)
                {
                    this.UserClaims.Remove(innerState);
                }
            }

            foreach (IUserPermissionStateEvent innerEvent in e.UserPermissionEvents)
            {
                IUserPermissionState innerState = this.UserPermissions.Get(innerEvent.GlobalId.PermissionId);

                innerState.Mutate(innerEvent);
                var removed = innerEvent as IUserPermissionStateRemoved;
                if (removed != null)
                {
                    this.UserPermissions.Remove(innerState);
                }
            }

            foreach (IUserLoginStateEvent innerEvent in e.UserLoginEvents)
            {
                IUserLoginState innerState = this.UserLogins.Get(innerEvent.GlobalId.LoginKey);

                innerState.Mutate(innerEvent);
                var removed = innerEvent as IUserLoginStateRemoved;
                if (removed != null)
                {
                    this.UserLogins.Remove(innerState);
                }
            }
        }