示例#1
0
        public static bool UpdateAccountInfo(AccountProfile identity)
        {
            if (identity.WinUser != Environment.UserName)
            {
                throw new InvalidOperationException("Permission denied");
            }

            RemoveIdentity(identity);

            return(AddAccountInfo(identity));
        }
示例#2
0
        private static bool RemoveIdentity(AccountProfile identity)
        {
            var identityToRemove = _identities.FirstOrDefault(i => i.WinUser == identity.WinUser & i.Account == identity.Account);

            if (null != identityToRemove)
            {
                _identities.Remove(identityToRemove);
            }

            return(true);
        }
示例#3
0
        public static bool AddAccountInfo(AccountType account, string login, string password, string token)
        {
            var identity = new AccountProfile()
            {
                WinUser  = Environment.UserName,
                Account  = account,
                Login    = login,
                Password = password,
                Token    = token
            };

            return(AddAccountInfo(identity));
        }
示例#4
0
        private static bool AddIdentity(AccountProfile identity)
        {
            var identityToUpdate = _identities.FirstOrDefault(i => i.WinUser == identity.WinUser & i.Account == identity.Account);

            if (null != identityToUpdate)
            {
                throw new InvalidOperationException("Identity already exists");
            }

            _identities.Add(identity);

            return(true);
        }
示例#5
0
        public static bool DeleteAccountInfo(AccountProfile identity)
        {
            if (identity.WinUser != Environment.UserName)
            {
                throw new InvalidOperationException("Permission denied");
            }

            var success = RemoveIdentity(identity);

            if (success)
            {
                SaveIdentityAccounts();
            }

            return(success);
        }
示例#6
0
        public static bool AddAccountInfo(AccountProfile identity)
        {
            if (String.IsNullOrEmpty(identity.WinUser))
            {
                identity.WinUser = Environment.UserName;
            }

            if (identity.WinUser != Environment.UserName)
            {
                throw new InvalidOperationException("Permission denied");
            }

            var success = AddIdentity(identity);

            if (success)
            {
                SaveIdentityAccounts();
            }

            return(success);
        }