Beispiel #1
0
        public void UpdateAccount(IAccount account)
        {
            if (account.Id == Account.InvalidId)
            {
                throw new AccountsException(AccountsErrors.InvalidId);
            }

            var newOne = new Account(account);
            var oldOne = accounts1.GetValue(account.Id);

            if (oldOne == null)
            {
                throw new AccountsException(AccountsErrors.OldNotFound);
            }
            if (string.IsNullOrEmpty(newOne.DomainName))
            {
                throw new AccountsException(AccountsErrors.DomainRequred);
            }

            if (newOne.DomainName != oldOne.DomainName)
            {
                if (accounts2.TryAdd(newOne.DomainName, newOne) == false)
                {
                    throw new AccountsException(AccountsErrors.DomainUsed);
                }
                accounts2.Remove(oldOne.DomainName);
            }

            files.IgnoryFileChanges(account.Id);
            newOne.Serialize(files.GetFileName(account.Id));
        }