public async Task GetPlayersAsync() { var playerRepos = new PlayerRepos(_dbConnection); var playerA = (await playerRepos.GetPlayerAsync("playerA")) .FirstOrDefault() ?? new Player() { Name = "null player", Age = 0 }; Console.WriteLine($"{playerA.Name}, {playerA.Age}"); var playerB = (await playerRepos.GetPlayerAsync("playerB")) .FirstOrDefault() ?? new Player() { Name = "null player", Age = 0 }; Console.WriteLine($"{playerB.Name}, {playerB.Age}"); var listPlayer = (await playerRepos.GetPlayersAsync()).ToList(); foreach (var aPlayer in listPlayer) { Console.WriteLine($"{aPlayer.Name}, {aPlayer.Age}"); } }
public async Task CreatePlayer(string dbName) { var playerRepos = new PlayerRepos(_dbConnection); if (File.Exists(dbName)) { return; } await playerRepos.CreatePlayerAsync(); }
public async Task AddPlayer() { var playerRepos = new PlayerRepos(_dbConnection); var listPlayer = new List <Player>() { new Player() { Name = "playerA", Age = 5 }, new Player() { Name = "playerB", Age = 15 }, new Player() { Name = "playerC", Age = 25 }, }; await playerRepos.AddPlayerAsync(listPlayer); }