//collect more summoners from existing dbEntries public void CollectSummoners() { int index = 100; int newSummonersFound = 0; int totalSummonersFound = 0; SummonerEntity summonerEnt = dbHelper.GetSummonerByIndex(index); while (summonerEnt != null) { Console.WriteLine($"Currently on index {index}"); MatchList matchList = new ApiRequest(requestStringHolder).Match.MatchList(summonerEnt.AccountId); foreach (Match match in matchList.matches) { MatchDetailed matchDetailed = new ApiRequest(requestStringHolder).Match.Match(match.gameId.ToString()); foreach (ParticipantIdentity pId in matchDetailed.participantIdentities) { string summonerName = pId.player.summonerName; Summoner summoner = new ApiRequest(requestStringHolder).Summoner.SummonerByName(summonerName); if (summoner != null) { SummonerEntity possibleNewSummoner = EntityFromRiotDto.GetSummoner(summoner); if (dbHelper.SubmitSummonerIfNotDuplicate(possibleNewSummoner)) { newSummonersFound++; } totalSummonersFound++; Console.Clear(); Console.WriteLine($"Found {totalSummonersFound} Summoners : {newSummonersFound} New Summoners"); } } } index++; } }
public bool SubmitSummonerIfNotDuplicate(SummonerEntity summoner) { if (!summonerAlreadyExists(summoner)) { context.Add(summoner); context.SaveChanges(); return(true); } return(false); }
public static SummonerEntity GetSummoner(Summoner summoner) { SummonerEntity result = new SummonerEntity(); result.AccountId = summoner.accountId; result.Name = summoner.name; result.ProfileIconId = summoner.profileIconId; result.RevisionDate = summoner.revisionDate; result.SummonerId = summoner.id; result.SummonerLevel = summoner.summonerLevel; return(result); }
//rteurns true if already exists. private bool summonerAlreadyExists(SummonerEntity summoner) { var queryResult = context.Summoners.Where(x => x.Name == summoner.Name).SingleOrDefault(); return(queryResult != null); }