Exemplo n.º 1
0
        public void Register(IAccount account)
        {
            if (account.GetName().Length <= 5)
            {
                throw new WrongAccountNameException();
            }
            string password = account.GetPassword();

            if (password.Length <= 8)
            {
                if (PasswordChecker.Validate(password) != CheckStatus.Ok)
                {
                    throw new WrongPasswordException();
                }
            }

            account.SetCreatedDate(new DateTime());
            var addresses = new List <IAddress>
            {
                account.GetHomeAddress(),
                account.GetWorkAddress(),
                account.GetAdditionalAddress()
            };

            account.SetAddresses(addresses);
            AccountManager.CreateNewAccount(account);
        }