Ejemplo n.º 1
0
        internal IEnumerable <EventOfMatch> GetFullEventsOfMatch(IEnumerable <EventOfMatch> eventsList)
        {
            int homeScore = 0;
            int awayScore = 0;

            foreach (var eventOfMatch in eventsList ?? Enumerable.Empty <EventOfMatch>())
            {
                eventOfMatch.HomeTeamScore    = 0;
                eventOfMatch.AwayTeamScore    = 0;
                eventOfMatch.HomeTeam         = eventOfMatch?.EventTeam == HomeTeam ? HomeTeam : string.Empty;
                eventOfMatch.AwayTeam         = eventOfMatch?.EventTeam == AwayTeam ? AwayTeam : string.Empty;
                eventOfMatch.HomeMainPlayer   = GetEventPlayer(eventOfMatch?.EventTeam.ToUpper().Trim() == HomeTeam.ToUpper().Trim() ? eventOfMatch?.MainPlayerOfMatchID : null);
                eventOfMatch.HomeSecondPlayer = GetEventPlayer(eventOfMatch?.EventTeam.ToUpper().Trim() == HomeTeam.ToUpper().Trim() ? eventOfMatch?.SecondPlayerOfMatchID : null);
                eventOfMatch.AwayMainPlayer   = GetEventPlayer(eventOfMatch?.EventTeam.ToUpper().Trim() == AwayTeam.ToUpper().Trim() ? eventOfMatch?.MainPlayerOfMatchID : null);
                eventOfMatch.AwaySecondPlayer = GetEventPlayer(eventOfMatch?.EventTeam.ToUpper().Trim() == AwayTeam.ToUpper().Trim() ? eventOfMatch?.SecondPlayerOfMatchID : null);


                eventOfMatch.HomeTeamVisible = eventOfMatch.HomeTeamVisible = !string.IsNullOrEmpty(eventOfMatch.HomeTeam);
                eventOfMatch.AwayTeamVisible = eventOfMatch.AwayTeamVisible = !string.IsNullOrEmpty(eventOfMatch.AwayTeam);

                if (IsGoal(eventOfMatch))
                {
                    if (eventOfMatch.EventTeam.ToUpper().Trim() == HomeTeam.ToUpper().Trim())
                    {
                        homeScore += 1;
                    }
                    if (eventOfMatch.EventTeam.ToUpper().Trim() == AwayTeam.ToUpper().Trim())
                    {
                        awayScore += 1;
                    }
                }
                eventOfMatch.HomeTeamScore = homeScore;
                eventOfMatch.AwayTeamScore = awayScore;

                if (eventOfMatch.EventName == "GOAL")
                {
                    int eventIndex = eventsList.ToList().IndexOf(eventOfMatch);
                    if (eventIndex + 1 < eventsList.Count())
                    {
                        EventOfMatch nextEvent = eventsList.ToList()[eventIndex + 1];
                        if (nextEvent.EventName == "ASSIST")
                        {
                            if (eventOfMatch.EventTeam.ToUpper().Trim() == HomeTeam.ToUpper().Trim())
                            {
                                eventOfMatch.HomeSecondPlayer = GetEventPlayer(nextEvent?.EventTeam.ToUpper().Trim() == HomeTeam.ToUpper().Trim() ? nextEvent?.MainPlayerOfMatchID : null);
                            }
                            if (eventOfMatch.EventTeam.ToUpper().Trim() == AwayTeam.ToUpper().Trim())
                            {
                                eventOfMatch.AwaySecondPlayer = GetEventPlayer(nextEvent?.EventTeam.ToUpper().Trim() == AwayTeam.ToUpper().Trim() ? nextEvent?.MainPlayerOfMatchID : null);
                            }
                        }
                    }
                }
            }

            return(eventsList);
        }
Ejemplo n.º 2
0
 bool IsGoal(EventOfMatch matchEvent)
 {
     return(matchEvent.EventName == "GOAL" ||
            matchEvent.EventName == "OWNGOAL" ||
            matchEvent.EventName == "PENALTYSCORED");
 }