コード例 #1
0
        /// <summary>
        /// Inserts an email account
        /// </summary>
        /// <param name="emailAccount">Email account</param>
        public virtual void InsertEmailAccount(EmailAccount emailAccount)
        {
            if (emailAccount == null)
            {
                throw new ArgumentNullException("emailAccount");
            }

            emailAccount.Email       = CodeHelper.EnsureNotNull(emailAccount.Email);
            emailAccount.DisplayName = CodeHelper.EnsureNotNull(emailAccount.DisplayName);
            emailAccount.Host        = CodeHelper.EnsureNotNull(emailAccount.Host);
            emailAccount.Username    = CodeHelper.EnsureNotNull(emailAccount.Username);
            emailAccount.Password    = CodeHelper.EnsureNotNull(emailAccount.Password);

            emailAccount.Email       = emailAccount.Email.Trim();
            emailAccount.DisplayName = emailAccount.DisplayName.Trim();
            emailAccount.Host        = emailAccount.Host.Trim();
            emailAccount.Username    = emailAccount.Username.Trim();
            emailAccount.Password    = emailAccount.Password.Trim();

            emailAccount.Email       = CodeHelper.EnsureMaximumLength(emailAccount.Email, 255);
            emailAccount.DisplayName = CodeHelper.EnsureMaximumLength(emailAccount.DisplayName, 255);
            emailAccount.Host        = CodeHelper.EnsureMaximumLength(emailAccount.Host, 255);
            emailAccount.Username    = CodeHelper.EnsureMaximumLength(emailAccount.Username, 255);
            emailAccount.Password    = CodeHelper.EnsureMaximumLength(emailAccount.Password, 255);
            emailAccount.CreatedOn   = DateTime.UtcNow;
            try
            {
                _emailAccountRepository.Add(emailAccount);
            }
            catch (Exception ex)
            {
                throw;
            }
        }