public void Register(Account account) { if (account == null) throw new ArgumentNullException("account"); using (AccountRepository accountRepository = new AccountRepository()) { if (accountRepository.CheckAccountExistByName(account.AccountName)) { // throw account name exists exception throw new AccountIsExistException(string.Format(Resource.ResourceMessage.ex_AccountExist, account.AccountName)); } var accounts = accountRepository.GetFiltered(a => a.Email == account.Email); if (accounts.Count<Account>() > 0) { // throw email exists exception throw new AccountEmailExistException(string.Format(Resource.ResourceMessage.ex_EmailExist, account.Email)); } accounts = accountRepository.GetFiltered(a => a.IdentityCardNumber == account.IdentityCardNumber); if (accounts.Count<Account>() > 0) { // throw IdentityCardNumber exists exception throw new AccountIdCardExistException(string.Format(Resource.ResourceMessage.ex_IdentityCardNumberExist, account.IdentityCardNumber)); } accountService.Register(account); accountRepository.Add(account); accountRepository.Commit(); // send a email to tell use his activation code so that he can activate the account SendMail(account, HostSendMail.EmailCategory.ActivationCode); } }
public void SendActivationMail(string email) { if (string.IsNullOrEmpty(email)) throw new ArgumentNullException("email"); using (AccountRepository accountRepository = new AccountRepository()) { var account = accountRepository.GetFiltered(a => a.Email == email).SingleOrDefault<Account>(); if (account != null && !account.IsActive) SendMail(account, HostSendMail.EmailCategory.ActivationCode); else { // throw account not exists exception throw new AccountNotExistException(Resource.ResourceMessage.ex_AccountIsNotExist); } } }
public void SendActivationMail(string email) { if (string.IsNullOrEmpty(email)) throw new ArgumentNullException("email"); AccountRepository accountRepository = new AccountRepository(); var account = accountRepository.GetFiltered( a => a.Email == email).SingleOrDefault<Account>(); if (account != null && !account.IsActive) SendMail(account, HostSendMail.EmailCategory.ActivationCode); else { //TODO: throw account not exists exception } }