Exemple #1
0
        private UserRegistration(
            string login,
            string password,
            string email,
            string firstName,
            string lastName,
            IUsersCounter usersCounter,
            string confirmLink)
        {
            this.CheckRule(new UserLoginMustBeUniqueRule(usersCounter, login));

            this.Id       = new UserRegistrationId(Guid.NewGuid());
            _login        = login;
            _password     = password;
            _email        = email;
            _firstName    = firstName;
            _lastName     = lastName;
            _name         = $"{firstName} {lastName}";
            _registerDate = DateTime.UtcNow;
            _status       = UserRegistrationStatus.WaitingForConfirmation;

            this.AddDomainEvent(new NewUserRegisteredDomainEvent(
                                    this.Id,
                                    _login,
                                    _email,
                                    _firstName,
                                    _lastName,
                                    _name,
                                    _registerDate,
                                    confirmLink));
        }
Exemple #2
0
        public void Expire()
        {
            this.CheckRule(new UserRegistrationCannotBeExpiredMoreThanOnceRule(_status));

            _status = UserRegistrationStatus.Expired;

            this.AddDomainEvent(new UserRegistrationExpiredDomainEvent(this.Id));
        }
Exemple #3
0
        public void Confirm()
        {
            this.CheckRule(new UserRegistrationCannotBeConfirmedMoreThanOnceRule(_status));
            this.CheckRule(new UserRegistrationCannotBeConfirmedAfterExpirationRule(_status));

            _status        = UserRegistrationStatus.Confirmed;
            _confirmedDate = DateTime.UtcNow;

            this.AddDomainEvent(new UserRegistrationConfirmedDomainEvent(this.Id));
        }