public void CollectMatchMvpData(MatchSubmissionView view, List <MatchDetailContract> matchList, Dictionary <string, SummonerInfoEntity> registeredPlayers, GameInfo gameInfo, Dictionary <int, MatchMvpEntity> mvpDetails, List <MatchMvpEntity> updateMvpDetails, List <MatchMvpEntity> insertMvpDetails, SummonerInfoEntity userPlayer) { var validMvpPlayers = new List <Guid>(); validMvpPlayers.AddRange(matchList.Select(x => x.MatchDetail.PlayerId)); registeredPlayers.TryGetValue(gameInfo.BlueMvp.ToLowerInvariant(), out var blueMvp); registeredPlayers.TryGetValue(gameInfo.RedMvp.ToLowerInvariant(), out var redMvp); registeredPlayers.TryGetValue(gameInfo.BlueMvp.ToLowerInvariant(), out var honoraryBlueOppMvp); registeredPlayers.TryGetValue(gameInfo.RedMvp.ToLowerInvariant(), out var honoraryRedOppMvp); if (mvpDetails.TryGetValue(gameInfo.GameNum, out var mvpEntity)) { if (!string.IsNullOrEmpty(gameInfo.BlueMvp) && blueMvp != null && blueMvp.Id != mvpEntity.BlueMvp && validMvpPlayers.Contains(blueMvp.Id)) { mvpEntity.BlueMvp = blueMvp.Id; } if (!string.IsNullOrEmpty(gameInfo.RedMvp) && redMvp != null && redMvp.Id != mvpEntity.RedMvp && validMvpPlayers.Contains(redMvp.Id)) { mvpEntity.RedMvp = redMvp.Id; } if (!string.IsNullOrEmpty(gameInfo.HonoraryBlueOppMvp) && honoraryBlueOppMvp != null && honoraryBlueOppMvp.Id != mvpEntity.HonoraryBlueOppMvp && validMvpPlayers.Contains(honoraryBlueOppMvp.Id)) { mvpEntity.HonoraryBlueOppMvp = honoraryBlueOppMvp.Id; } if (!string.IsNullOrEmpty(gameInfo.HonoraryRedOppMvp) && honoraryRedOppMvp != null && honoraryRedOppMvp.Id != mvpEntity.HonoraryRedOppMvp && validMvpPlayers.Contains(honoraryRedOppMvp.Id)) { mvpEntity.HonoraryRedOppMvp = honoraryRedOppMvp.Id; } mvpEntity.UpdatedBy = userPlayer.SummonerName; mvpEntity.UpdatedOn = DateTime.Now; updateMvpDetails.Add(mvpEntity); } else { mvpEntity = new MatchMvpEntity { Id = Guid.NewGuid(), BlueMvp = blueMvp != null && validMvpPlayers.Contains(blueMvp.Id) ? blueMvp.Id : new Guid?(), RedMvp = redMvp != null && validMvpPlayers.Contains(redMvp.Id) ? redMvp.Id : new Guid?(), Game = gameInfo.GameNum, TeamScheduleId = view.ScheduleId, CreatedBy = userPlayer.SummonerName, CreatedOn = DateTime.Now }; insertMvpDetails.Add(mvpEntity); } }
public void CollectMatchMvpData(SimplifiedMatchSubmissionView view, Dictionary <string, SummonerInfoEntity> registeredPlayers, GameDetail gameInfo, Dictionary <int, MatchMvpEntity> mvpDetails, List <MatchMvpEntity> updateMvpDetails, List <MatchMvpEntity> insertMvpDetails, SummonerInfoEntity userPlayer) { registeredPlayers.TryGetValue(gameInfo.BlueMvp.ToLowerInvariant(), out var blueMvp); registeredPlayers.TryGetValue(gameInfo.RedMvp.ToLowerInvariant(), out var redMvp); registeredPlayers.TryGetValue(gameInfo.HonoraryBlueOppMvp.ToLowerInvariant(), out var honoraryBlueOppMvp); registeredPlayers.TryGetValue(gameInfo.HonoraryRedOppMvp.ToLowerInvariant(), out var honoraryRedOppMvp); if (mvpDetails.TryGetValue(gameInfo.GameNum, out var mvpEntity)) { if (!string.IsNullOrEmpty(gameInfo.BlueMvp) && blueMvp != null && blueMvp.Id != mvpEntity.BlueMvp) { mvpEntity.BlueMvp = blueMvp.Id; } if (!string.IsNullOrEmpty(gameInfo.RedMvp) && redMvp != null && redMvp.Id != mvpEntity.RedMvp) { mvpEntity.RedMvp = redMvp.Id; } if (!string.IsNullOrEmpty(gameInfo.HonoraryBlueOppMvp) && honoraryBlueOppMvp != null && honoraryBlueOppMvp.Id != mvpEntity.HonoraryBlueOppMvp) { mvpEntity.HonoraryBlueOppMvp = honoraryBlueOppMvp.Id; } if (!string.IsNullOrEmpty(gameInfo.HonoraryRedOppMvp) && honoraryRedOppMvp != null && honoraryRedOppMvp.Id != mvpEntity.HonoraryRedOppMvp) { mvpEntity.HonoraryRedOppMvp = honoraryRedOppMvp.Id; } mvpEntity.UpdatedBy = userPlayer.SummonerName; mvpEntity.UpdatedOn = DateTime.Now; updateMvpDetails.Add(mvpEntity); } else { mvpEntity = new MatchMvpEntity { Id = Guid.NewGuid(), BlueMvp = blueMvp?.Id, RedMvp = redMvp?.Id, HonoraryBlueOppMvp = honoraryBlueOppMvp?.Id, HonoraryRedOppMvp = honoraryRedOppMvp?.Id, Game = gameInfo.GameNum, TeamScheduleId = view.ScheduleId, CreatedBy = userPlayer.SummonerName, CreatedOn = DateTime.Now }; insertMvpDetails.Add(mvpEntity); } }