public LAMatch GetMatch(Match riotmatch) { LAMatch match = new LAMatch(); // Renamed Match to LAMatch, not a perfect name but works match.MatchID = riotmatch.GameId; match.RegionID = (int)Region.Na; match.DatePlayed = riotmatch.GameCreation; match.DurationSeconds = riotmatch.GameDuration.TotalSeconds; match.SeasonID = riotmatch.SeasonId; match.GameVersion = riotmatch.GameVersion; match.GameMode = riotmatch.GameMode; match.GameType = riotmatch.GameType; match.MapID = riotmatch.MapId; matchIO.InsertMatch(match); return(match); }
// Summary: // Honestly I'm not 100% on inserting all of these huge objects properly, here we go! protected void btnTestInsertMatch_Click(object sender, EventArgs e) { try { string message = ""; var riotMatch = api.Match.GetMatchAsync(Region.Na, 3223236153).Result; LAMatch newMatch = new LAMatch(riotMatch.GameId, (int)Region.Na, riotMatch.GameCreation, riotMatch.GameDuration.TotalSeconds, riotMatch.SeasonId, riotMatch.GameVersion, riotMatch.GameMode, riotMatch.GameType, riotMatch.MapId); message = matchIO.InsertMatch(newMatch).ToString(); lblMessage.Text = message; } catch (Exception ex) { Response.Write(ex.Message.ToString()); } }
// Summary: // If the summoner exists pull summoner data // If the summoner doesn't exist insert into db protected void btnSearch_Click(object sender, EventArgs e) { Summoner searchedSummoner; Summoner queriedSummoner; LAMatch match; try { string search = txtSearch.Text; string summonerID = ""; string accountID = ""; string message = ""; // Just making sure the text box isn't blank, I will also add a validation later if (search != "") { var summoner = api.Summoner.GetSummonerByNameAsync(Region.Na, search).Result; summonerID = summoner.Id; accountID = summoner.AccountId; searchedSummoner = new Summoner(summonerID, summoner.Name, summoner.AccountId, summoner.ProfileIconId); // If exists, return info if (summonerIO.SummonerExists(summonerID)) { // TODO: // Check each match if exists in the DB // Check for participants and their stats queriedSummoner = summonerIO.GetSummonerByID(summonerID); var matches = api.Match.GetMatchListAsync(Region.Na, accountID).Result.Matches; // To do this i believe i have to search each match via riot's api :( big oof int matchlistlen = matches.Count; //for (int x = 0; x < 1; x++) // 1 most recent matches? for (int x = 0; x < 10; x++) // 10 most recent matches { // If the match already exists in the DB // Don't Search for it via the Riot API and // Don't try inserting it in the DB if (!matchIO.MatchExists(matches[x].GameId)) { // I assume I am going to get rate limited by this var riotmatch = api.Match.GetMatchAsync(Region.Na, matches[x].GameId).Result; match = new LAMatch(); // I see why i'm having warnings now :( I should rename this match.MatchID = riotmatch.GameId; match.RegionID = (int)Region.Na; match.DatePlayed = riotmatch.GameCreation; // This might be in accurate match.DurationSeconds = riotmatch.GameDuration.TotalSeconds; match.SeasonID = riotmatch.SeasonId; match.GameVersion = riotmatch.GameVersion; match.GameMode = riotmatch.GameMode; match.GameType = riotmatch.GameType; match.MapID = riotmatch.MapId; matchIO.InsertMatch(match); // Need to make sure to pass in the RiotSharp match // This will also insert the stats var participants = participantManager.GetMatchParticipants(riotmatch); message += match.MatchID + "<br />"; for (int y = 0; y < participants.Count; y++) { message += participants[y].SummonerID + "<br />"; } } } } else // If not exists, insert summoner and then output generic return code { // TODO: Since they do not exists their matches also 'should' not exist in the DB // So we need to insert them message += summonerIO.InsertSummoner(searchedSummoner).ToString(); } } else { message = "Please search a summoner!"; } lblMessage.Text = message; } catch (Exception ex) { // TODO: Proper Exception catching Response.Write(ex.ToString()); } }