Example #1
0
        private bool Equals([NotNull] GivenNames other)
        {
            if (this._names.Count != other._names.Count)
            {
                return(false);
            }
            var thisEnumerator  = this._names.GetEnumerator();
            var otherEnumerator = other._names.GetEnumerator();

            while (thisEnumerator.MoveNext() && otherEnumerator.MoveNext())
            {
                if (!Equals(thisEnumerator.Current, otherEnumerator.Current))
                {
                    return(false);
                }
            }
            return(true);
        }
Example #2
0
 public FullName(Name familyName, GivenNames givenNames = null)
 {
     Contract.Requires(familyName != null);
     FamilyName = familyName;
     GivenNames = givenNames;
 }
Example #3
0
 public override string ToString()
 {
     return(string.Join(" ", GivenNames.ToString(), FamilyName.ToString()));
 }
Example #4
0
 public override int GetHashCode()
 {
     unchecked {
         return((FamilyName.GetHashCode() * 397) ^ (GivenNames != null ? GivenNames.GetHashCode() : 0));
     }
 }
Example #5
0
 public FullName(Name familyName, GivenNames givenNames = null)
 {
     Contract.Requires(familyName != null);
     FamilyName = familyName;
     GivenNames = givenNames;
 }
Example #6
0
        public ActionResult SignUp(AccountRegistration information)
        {
            var username = new Username(information.Username);

            bool usernameIsAvailable = _accountRegistrationService.IsUsernameAvailable(username);
            if (!usernameIsAvailable) {
                TempData.RegistrationFailureReason.Store(RegistrationFailureReason.UsernameNotAvailable);
                TempData.AccountRegistrationInformation.Store(information);
                return RedirectToAction<AccountController>(c => c.SignUp());
            }

            var password = new Password(information.Password);
            var passwordConfirmation = new Password(information.PasswordConfirmation);
            if (!password.Equals(passwordConfirmation)) {
                TempData.RegistrationFailureReason.Store(RegistrationFailureReason.PasswordsDoNotMatch);
                return RedirectToAction<AccountController>(c => c.SignUp());
            }

            var emailAddress = new EmailAddress(information.Email);
            var emailAddressConfirmation = new EmailAddress(information.EmailConfirmation);
            if (!emailAddress.Equals(emailAddressConfirmation)) {
                TempData.RegistrationFailureReason.Store(RegistrationFailureReason.EmailsDoNotMatch);
                return RedirectToAction<AccountController>(c => c.SignUp());
            }

            var foo = new GivenNames();

            var fullName = new FullName(new Name(information.LastName), new GivenNames(information.FirstName));
            var accountRegistration = new AccountManagement.AccountRegistration(username, password, fullName, new EmailAddress(information.Email));
            _accountRegistrationService.CreateAccount(accountRegistration);

            TempData.NewAccountUsername.Store(accountRegistration.Username);
            return RedirectToAction<AccountController>(c => c.SignUpComplete());
        }