private void ValidateAgainstExistingAccounts(User user, Interfaces.Model.AccountType originalAccountType, AccountType mappedAccountType, string accountName) { if (repository.AccountExists(mappedAccountType, accountName)) { throw new UserAccountAlreadyAssignedException(accountName); } if (user.HasAccountType(mappedAccountType)) { throw new UserAccountTypeAlreadyAssignedException(originalAccountType); } }
private void ThrowIfAccountNameIsAlreadyAssigned(AccountType type, string name, string newName) { if (!name.Equals(newName, StringComparison.InvariantCultureIgnoreCase) && repository.AccountExists(type, newName)) { throw new UserAccountAlreadyAssignedException(newName); } }