public List <MatchupInfos> ConvertMatchupsToMatchupInfos(List <Matchup> listMatchup, List <MatchupComment> listMatchupComment)

        {
            List <MatchupInfos> matchupInfos = new List <MatchupInfos>();

            if (listMatchup?.Count > 0)
            {
                foreach (var matchup in listMatchup)
                {
                    MatchupInfos matchupInfo = new MatchupInfos();
                    matchupInfo.MatchupId         = matchup.MatchupId;
                    matchupInfo.MatchupResponseId = matchup.MatchupResponseId;
                    matchupInfo.AllyTop           = matchup.AllyTop.Value;
                    matchupInfo.AllyJungle        = matchup.AllyJungle.Value;
                    matchupInfo.AllyMid           = matchup.AllyMid.Value;
                    matchupInfo.AllyAdc           = matchup.AllyAdc.Value;
                    matchupInfo.AllySupport       = matchup.AllySupport.Value;

                    matchupInfo.EnemyTop     = matchup.EnemyTop.Value;
                    matchupInfo.EnemyJungle  = matchup.EnemyJungle.Value;
                    matchupInfo.EnemyMid     = matchup.EnemyMid.Value;
                    matchupInfo.EnemyAdc     = matchup.EnemyAdc.Value;
                    matchupInfo.EnemySupport = matchup.EnemySupport.Value;
                    matchupInfo.PatchVersion = matchup.PatchVersion;
                    var matchupResponse = db.MatchupResponses.Where(x => x.MatchupResponseId == matchup.MatchupResponseId);
                    matchupInfo.Answers = new List <MatchupAnswer>();
                    foreach (var response in matchupResponse)
                    {
                        var matchupAnswer = new MatchupAnswer();
                        matchupAnswer.MatchupCommentId = response.MatchupResponseId;
                        matchupAnswer.ChampionId       = response.ChampionId;
                        matchupAnswer.Comments         = listMatchupComment.Where(x => x.MatchupId == matchup.MatchupId && x.ChampionId == response.ChampionId).OrderByDescending(x => x.CreationDate).FirstOrDefault()?.CommentText;
                        matchupInfo.Answers.Add(matchupAnswer);
                    }
                    matchupInfo.Answers = matchupInfo.Answers.OrderBy(x => x.ChampionName).ToList();
                    matchupInfos.Add(matchupInfo);
                }
            }
            return(matchupInfos);
        }
Beispiel #2
0
        private MatchupInfos CreateAutomaticMatchupInfo(MatchupInfos matchupInfos, List <Guid> listMatchupResponse)
        {
            MatchupInfos automaticMatchupInfo = new MatchupInfos();

            automaticMatchupInfo         = matchupInfos.DuplicateMe(matchupInfos);
            automaticMatchupInfo.Answers = new List <MatchupAnswer>();

            foreach (Guid matchupResponseId in listMatchupResponse)
            {
                var matchupResponses = db.MatchupResponses.Where(x => x.MatchupResponseId == matchupResponseId).ToList();
                foreach (var matchupResponse in matchupResponses)
                {
                    var matchupAnswer = new MatchupAnswer();
                    matchupAnswer.ChampionId = matchupResponse.ChampionId;
                    if (!automaticMatchupInfo.Answers.Where(x => x.ChampionId == matchupResponse.ChampionId).Any())
                    {
                        automaticMatchupInfo.Answers.Add(matchupAnswer);
                    }
                }
                automaticMatchupInfo.Answers = automaticMatchupInfo.Answers.OrderBy(x => x.ChampionName).ToList();
            }

            return(automaticMatchupInfo);
        }