public async Task<bool> RemoveAccountAsync(Account accountToRemove) { List<Account> accounts = await GetAccountListAsync(); Account accountFromJson = accounts.FirstOrDefault(a => a.SteamId == accountToRemove.SteamId); if (accountFromJson == null) return false; accounts.Remove(accountFromJson); string json = await Task.Factory.StartNew(() => JsonConvert.SerializeObject(accounts)); string pathAccountsFileJson = _pathFolderCache + "\\" + ACCOUNTS_FILENAME; File.WriteAllText(pathAccountsFileJson, json); return true; }
public Task<bool> RemoveAccountAsync(Account account) { return Task.FromResult(true); }
public async Task<bool> AddAccountAsync(Account newAccount) { // Get current list List<Account> accounts = await GetAccountListAsync(); // Check if already in the list if (accounts.Any(account => account.SteamId == newAccount.SteamId)) return false; accounts.Add(newAccount); // If not add it and update string json = await Task.Factory.StartNew(() => JsonConvert.SerializeObject(accounts)); string pathAccountsFileJson = _pathFolderCache + "\\" + ACCOUNTS_FILENAME; File.WriteAllText(pathAccountsFileJson, json); return true; }