예제 #1
0
		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);
		}
예제 #3
0
		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;
		}