private async Task <IEnumerable <MatchDetailsModel> > GetMatchStored(MatchBaseRequest request) { var matchDetails = await _unitOfWorkManager.ExecuteSingleAsync <IMatchDetailsRepository, IEnumerable <MatchDetailsModel> > (u => u.GetMatchDetails(request)); if (matchDetails.Any()) { return(matchDetails); } return(null); }
public async Task <List <MatchDetailsClientModel> > GetClientMatchDetailsAsync(MatchBaseRequest request) { var response = await SendRequestAsync <List <MatchDetailsClientModel> >(_requestUrlBuilder.BuildMatchDetailsUrl(request.SessionId, request.MatchId)); await LogUsageStat(ActionNameConstants.GetMatchDetails); return(HandleRetMessageReponse(response)); }
public async Task <Response <List <MatchDetailsModel> > > GetMatchDetailsAsync(MatchBaseRequest request) { request.SessionId = await _sessionManager.GetKey(); var response = new Response <List <MatchDetailsModel> >(); var matchDetails = await _unitOfWorkManager.ExecuteSingleAsync <IMatchDetailsRepository, IEnumerable <MatchDetailsModel> > (u => u.GetMatchDetails(request)); if (matchDetails.Any()) { response.Data = matchDetails.ToList(); } else { var clientResponse = await _matchClient.GetClientMatchDetailsAsync(request); var mapped = clientResponse.Select(x => _matchDetailsMapper.Map(x)); var storedResponse = await _unitOfWorkManager.ExecuteSingleAsync <IMatchDetailsRepository, DataListResult <MatchDetailsModel> > (u => u.InsertMatchDetailsEntry(mapped, request)); var detailedMatch = await _unitOfWorkManager.ExecuteSingleAsync <IMatchDetailsRepository, IEnumerable <MatchDetailsModel> > (u => u.GetMatchDetails(request)); response.Data = detailedMatch.ToList(); } return(response); }
public async Task <Response <IEnumerable <MatchDetailsModel> > > GetMatchDetailsAsync(MatchBaseRequest request) { var validationResponse = _responseValidator.Validate(request); var response = new Response <IEnumerable <MatchDetailsModel> > { ValidationResults = _responseValidator.Map(validationResponse) }; if (!response.ValidationResults.IsValid) { return(response); } response.Data = await GetMatchStored(request); if (response.Data.IsNotNull()) { return(response); } request.SessionId = await _sessionManager.GetKey(); var clientResponse = await _matchClient.GetClientMatchDetailsAsync(request); response.Data = clientResponse.Select(x => _matchDetailsMapper.Map(x)); response = await MapChampionDetails(response); return(response); }
public async Task <DataListResult <MatchDetailsModel> > InsertMatchDetailsEntry(IEnumerable <MatchDetailsModel> model, MatchBaseRequest request) { var matchDetails = model.Select(x => new MatchDetails { PlayerMatchHistoryId = request.PlayerMatchHistoryId, DamageDoneInHand = x.DamageDoneInHand, DamageMitigated = x.DamageMitigated, DamageTaken = x.DamageTaken, Deaths = x.Deaths, GoldEarnedPerMinute = x.GoldEarnedPerMinute, GoldEarnedTotal = x.GoldEarnedTotal, HasReplay = x.HasReplay, HealingDone = x.HealingDone, KillingSpree = x.KillingSpree, Assists = x.Assists, ObjectiveAssists = x.ObjectiveAssists, Kills = x.Kills, KillsDouble = x.KillsDouble, KillsPenta = x.KillsPenta, KillsQuadra = x.KillsQuadra, KillsTriple = x.KillsTriple, LeageWins = x.LeagueWins, LeagueLosses = x.LeagueLosses, LeaguePoints = x.LeaguePoints, LeagueTier = x.LeagueTier, Length = x.Length, LengthInMinutes = x.LengthInMinutes, PchampionId = x.PaladinsChampionId, PplayerId = x.PaladinsPlayerId, PmatchId = x.PaladinsMatchId, MapGameType = x.MapGameType, MapName = x.MapName, MultiKillMax = x.MultiKillMax, PchampionSkinId = x.PaladinsChampionSkinId, PqueueId = x.PaladinsQueueId, PlayerAccountLevel = x.PlayerAccountLevel, PlayerName = x.PlayerName, Region = x.Region, SelfHealing = x.SelfHealing, TeamOneScore = x.TeamOneScore, TeamTwoScore = x.TeamTwoScore, WinStatus = x.WinStatus, ItemsBought = x.ItemsBought.Select(i => new ItemsBought { ItemLevel = i.ItemLevel, ItemName = i.ItemName, ItemOrder = i.ItemOrder, PitemId = i.PaladinsItemId, IsActive = IsActiveConstants.True, }).ToHashSet(), MatchBans = x.MatchBans.Where(p => x.MapName.Contains("Ranked")).Select(i => new MatchBans { BanPosition = i.BanPosition, ChampionName = i.ChampionName, PchampionId = i.PaladinsChampionId, PmatchId = i.PaladinsMatchId, IsActive = IsActiveConstants.True, }).ToHashSet(), LoadoutsSelected = x.LoadoutSelected.Select(i => new LoadoutSelected { LoadoutItemLevel = i.LoadoutItemLevel, LoadoutItemName = i.LoadoutItemName, PitemId = i.PaladinsItemId, PmatchId = i.PaladinsMatchId, PplayerId = i.PaladinsPlayerId, IsActive = IsActiveConstants.True, }).ToHashSet(), }); var response = await InsertListAsync(matchDetails); return(new DataListResult <MatchDetailsModel>(response.RowsAffected, model)); }
public async Task <IEnumerable <MatchDetailsModel> > GetMatchDetails(MatchBaseRequest request) { return(await Context.MatchDetails .Include(x => x.MatchBans) .Include(x => x.LoadoutsSelected) .Where(x => x.PmatchId == Convert.ToInt32(request.MatchId)) .Select(x => new MatchDetailsModel { Id = x.Id, Assists = x.Assists, ObjectiveAssists = x.ObjectiveAssists, DamageDoneInHand = x.DamageDoneInHand, DamageMitigated = x.DamageMitigated, DamageTaken = x.DamageTaken, Deaths = x.Deaths, GoldEarnedPerMinute = x.GoldEarnedPerMinute, GoldEarnedTotal = x.GoldEarnedTotal, HasReplay = x.HasReplay, HealingDone = x.HealingDone, ItemsBought = x.ItemsBought.Select(i => new ItemsBoughtModel { ItemLevel = i.ItemLevel, ItemName = i.ItemName, ItemOrder = i.ItemOrder, PaladinsItemId = i.PitemId, }), KillingSpree = x.KillingSpree, Kills = x.Kills, KillsDouble = x.KillsDouble, KillsPenta = x.KillsPenta, KillsQuadra = x.KillsQuadra, KillsTriple = x.KillsTriple, LeagueWins = x.LeageWins, LeagueLosses = x.LeagueLosses, LeaguePoints = x.LeaguePoints, LeagueTier = x.LeagueTier, Length = x.Length, LengthInMinutes = x.LengthInMinutes, LoadoutSelected = x.LoadoutsSelected.Select(i => new LoadoutSelectedModel { LoadoutItemLevel = i.LoadoutItemLevel, LoadoutItemName = i.LoadoutItemName, PaladinsItemId = i.PitemId, PaladinsMatchId = i.PmatchId, PaladinsPlayerId = i.PplayerId, }), PaladinsChampionId = x.PchampionId, ChampionName = x.Champion.Name, ChampionIconUrl = x.Champion.Url, PaladinsPlayerId = x.PplayerId, PaladinsMatchId = x.PmatchId, MapGameType = x.MapGameType, MapName = x.MapName, MatchBans = x.MatchBans.Select(i => new MatchBansModel { BanPosition = i.BanPosition, ChampionName = i.ChampionName, ChampionIconUrl = i.Pchampion.Url, PaladinsChampionId = i.PchampionId, PaladinsMatchId = i.PmatchId, }), MultiKillMax = x.MultiKillMax, PaladinsChampionSkinId = x.PchampionSkinId, PaladinsQueueId = x.PqueueId, PlayerAccountLevel = x.PlayerAccountLevel, PlayerName = x.PlayerName, Region = x.Region, SelfHealing = x.SelfHealing, TeamOneScore = x.TeamOneScore, TeamTwoScore = x.TeamTwoScore, WinStatus = x.WinStatus }) .ToListAsync()); }