public static bool UpdateAccountInfo(AccountProfile identity) { if (identity.WinUser != Environment.UserName) { throw new InvalidOperationException("Permission denied"); } RemoveIdentity(identity); return(AddAccountInfo(identity)); }
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); }
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)); }
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); }
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); }
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); }