private async Task IncrementPlayerStats(SongData song, Dictionary <string, int> tempDict, Player player, string rule) { int listnum = 0; //tempDict is a dictionary which contains player names and integers which represent list status if (tempDict != null && tempDict.ContainsKey(player.name)) { listnum = tempDict[player.name]; } if (player.correct) { //Console.WriteLine("Found this object so just updating their times played and correct by 1."); var temp = await _db.FindAsync <PlayerTableObject>(MakePlayerTableKey(song.anime.english, song.type, song.name, player.name, rule)); temp.TotalTimesPlayed += 1; temp.TimesCorrect += 1; if (tempDict != null) { temp.FromList = listnum; } } else { //Console.WriteLine("Found this object so just updating their times played by 1."); var temp = await _db.FindAsync <PlayerTableObject>(MakePlayerTableKey(song.anime.english, song.type, song.name, player.name, rule)); temp.TotalTimesPlayed += 1; temp.FromList = listnum; if (tempDict != null) { temp.FromList = listnum; } } }
public static async Task <SongTableObject> UseSongKey(CsharpiEntities _db, string key) { var song = await _db.FindAsync <SongTableObject>(key); if (song != null) { return(song); } var result = await _db.SongTableObject .AsNoTracking() .Where(x => x.Key.ToLower().Equals(key.ToLower())) .ToListAsync(); return(result[0]); }