public async Task <ArenaMatch> GetArenaMatch(Guid id) { //ArenaMatchData data = await _db.FindAsync<ArenaMatchData>(id.ToString()); //if (data == null) //{ var query = new GetArenaMatchDetails().ForMatchId(id); var match = await _session.Query(query); if (match == null) { return(null); } await PopulateBaseMatch(match); foreach (var teamStat in match.TeamStats) { teamStat.TeamColor = await _metadataRepository.GetTeamColor(teamStat.TeamId); } foreach (var playerStat in match.PlayerStats) { playerStat.CurrentSpartanRank = await _metadataRepository.GetSpartanRank(playerStat.XpInfo.SpartanRank); playerStat.NextSpartanRank = await _metadataRepository.GetSpartanRank(playerStat.XpInfo.SpartanRank + 1); if (playerStat.CurrentCsr != null || (playerStat.MeasurementMatchesLeft > 0 && playerStat.MeasurementMatchesLeft < 10)) { if (playerStat.CurrentCsr == null) { playerStat.CurrentCsr = new CompetitiveSkillRanking { DesignationId = Enumeration.CompetitiveSkillRankingDesignation.Unranked, Tier = 10 - playerStat.MeasurementMatchesLeft }; } var csr = await _metadataRepository.GetCompetitiveSkillRankDesignation((int)playerStat.CurrentCsr.DesignationId); var tier = csr.Tiers.SingleOrDefault(t => t.Id == (playerStat.CurrentCsr.Tier)); csr.Tiers = null; playerStat.CurrentCsr.Designation = csr; playerStat.CurrentCsr.CurrentTier = tier; if (playerStat.PreviousCsr == null && playerStat.MeasurementMatchesLeft != 0) { playerStat.PreviousCsr = new CompetitiveSkillRanking { DesignationId = Enumeration.CompetitiveSkillRankingDesignation.Unranked, Tier = playerStat.MeasurementMatchesLeft != 10 ? 10 - playerStat.MeasurementMatchesLeft - 1 : -1 }; } if (playerStat.PreviousCsr != null) { csr = await _metadataRepository.GetCompetitiveSkillRankDesignation((int)playerStat.PreviousCsr.DesignationId); tier = csr.Tiers.SingleOrDefault(t => t.Id == (playerStat.PreviousCsr.Tier)); csr.Tiers = null; playerStat.PreviousCsr.Designation = csr; playerStat.PreviousCsr.CurrentTier = tier; } } await PopulatePlayer(playerStat); } //data = new ArenaMatchData(id, match); //_db.InsertAsync(data); return(match); //} //return data.Deserialize(); }