private void AddTeamStatistic(EventOfMatch matchEvent, TeamStatistic teamStatistic) { switch (matchEvent?.EventName?.ToLower()) { case "goal": case "penaltyscored": teamStatistic.Goal += 1; teamStatistic.OnTarget += 1; break; case "owngoal": teamStatistic.Goal += 1; break; case "yellow": teamStatistic.YellowCard += 1; break; case "red": teamStatistic.RedCard += 1; break; case "corner": teamStatistic.Corner += 1; break; case "ontarget": teamStatistic.OnTarget += 1; break; case "offtarget": teamStatistic.OffTarget += 1; break; case "blockedshot": teamStatistic.BlockedShot += 1; break; case "bigchance": teamStatistic.BigChance += 1; break; } }
bool IsGoal(EventOfMatch matchEvent) { return(matchEvent.EventName == "GOAL" || matchEvent.EventName == "OWNGOAL" || matchEvent.EventName == "PENALTYSCORED"); }
private 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 == Match?.HomeTeam ? Match?.HomeTeam : string.Empty; eventOfMatch.AwayTeam = eventOfMatch?.EventTeam == Match?.AwayTeam ? Match?.AwayTeam : string.Empty; eventOfMatch.HomeMainPlayer = GetEventPlayer(eventOfMatch?.EventTeam.ToUpper().Trim() == Match?.HomeTeam?.ToUpper().Trim() ? eventOfMatch?.MainPlayerOfMatchID : null); eventOfMatch.HomeSecondPlayer = GetEventPlayer(eventOfMatch?.EventTeam.ToUpper().Trim() == Match?.HomeTeam?.ToUpper().Trim() ? eventOfMatch?.SecondPlayerOfMatchID : null); eventOfMatch.AwayMainPlayer = GetEventPlayer(eventOfMatch?.EventTeam.ToUpper().Trim() == Match?.AwayTeam?.ToUpper().Trim() ? eventOfMatch?.MainPlayerOfMatchID : null); eventOfMatch.AwaySecondPlayer = GetEventPlayer(eventOfMatch?.EventTeam.ToUpper().Trim() == Match?.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() == Match?.HomeTeam?.ToUpper().Trim()) { homeScore += 1; } if (eventOfMatch.EventTeam.ToUpper().Trim() == Match?.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() == Match?.HomeTeam?.ToUpper().Trim()) { eventOfMatch.HomeSecondPlayer = GetEventPlayer(nextEvent?.EventTeam.ToUpper().Trim() == Match?.HomeTeam?.ToUpper().Trim() ? nextEvent?.MainPlayerOfMatchID : null); } if (eventOfMatch.EventTeam.ToUpper().Trim() == Match?.AwayTeam?.ToUpper().Trim()) { eventOfMatch.AwaySecondPlayer = GetEventPlayer(nextEvent?.EventTeam.ToUpper().Trim() == Match?.AwayTeam?.ToUpper().Trim() ? nextEvent?.MainPlayerOfMatchID : null); } } } } eventOfMatch.ShowResult = eventOfMatch?.EventName?.ToUpper() == "GOAL" || eventOfMatch?.EventName?.ToUpper() == "OWNGOAL" || eventOfMatch?.EventName?.ToUpper() == "PENALTYSCORED"; eventOfMatch.ShowSecondPlayer = eventOfMatch?.EventName?.ToUpper() == "SUBSTITUTION"; } return(eventsList); }