Пример #1
0
        /// <summary>
        /// Updates an email account
        /// </summary>
        /// <param name="emailAccount">Email account</param>
        public virtual void UpdateEmailAccount(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);

            _emailAccountRepository.Update(emailAccount);
        }
Пример #2
0
        public IEnumerable <IEvent> Handle(DeleteEmailAccount command)
        {
            var emailAccount = _emailAccountRepository.GetById(command.SiteId, command.Id);

            if (emailAccount == null)
            {
                throw new Exception("Email Account not found.");
            }

            emailAccount.Delete(command, _validator);

            _emailAccountRepository.Update(emailAccount);

            return(emailAccount.Events);
        }
Пример #3
0
        public ICollection <IEvent> Handle(UpdateEmailAccountDetails command)
        {
            var emailAccount = _emailAccountRepository.GetById(command.SiteId, command.Id);

            if (emailAccount == null)
            {
                throw new Exception("Email Account not found.");
            }

            emailAccount.UpdateDetails(command, _validator);

            _emailAccountRepository.Update(emailAccount);

            return(emailAccount.Events);
        }