Esempio n. 1
0
        public string SetDefaultAccount(string email, bool isDefault)
        {
            if (string.IsNullOrEmpty(email))
            {
                throw new ArgumentNullException("email");
            }

            email = email.ToLowerInvariant();
            if (isDefault)
            {
                var  accounts   = MailBoxManager.GetAccountInfo(TenantId, Username);
                bool emailExist = false;

                for (int i = 0; i < accounts.Count; i++)
                {
                    if (accounts[i].Email == email)
                    {
                        emailExist = true;
                        break;
                    }
                    for (int j = 0; j < accounts[i].Aliases.Count; j++)
                    {
                        if (accounts[i].Aliases[j].Email == email)
                        {
                            emailExist = true;
                            break;
                        }
                    }
                }
                if (!emailExist)
                {
                    throw new ArgumentException(String.Format("Account wasn't founded by email: {0}", email));
                }
            }
            var settings = new MailBoxAccountSettings
            {
                DefaultEmail = isDefault ? email : String.Empty
            };

            SettingsManager.Instance.SaveSettingsFor <MailBoxAccountSettings>(settings, SecurityContext.CurrentAccount.ID);

            return(email);
        }
Esempio n. 2
0
        public string SetDefaultAccount(string email, bool setDefault)
        {
            if (string.IsNullOrEmpty(email))
                throw new ArgumentNullException("email");
            email = email.ToLowerInvariant();
            if (setDefault)
            {
                var accounts = MailBoxManager.GetAccountInfo(TenantId, Username);
                bool emailExist = false;
                
                for (int i = 0; i < accounts.Count; i++)
                {
                    if (accounts[i].Email == email)
                    {
                        emailExist = true;
                        break;
                    }
                    for (int j = 0; j < accounts[i].Aliases.Count; j++)
                    {
                        if (accounts[i].Aliases[j].Email == email)
                        {
                            emailExist = true;
                            break;
                        }
                    }
                }
                if (!emailExist)
                    throw new ArgumentException(String.Format("Account wasn't founded by email: {0}", email));
            }
            var settings = new MailBoxAccountSettings
            {
                DefaultEmail = setDefault ? email : String.Empty
            };
            SettingsManager.Instance.SaveSettingsFor<MailBoxAccountSettings>(settings, SecurityContext.CurrentAccount.ID);

            return email;
        }