示例#1
0
        private static void ProcessMatch(this BaseMatchViewModel matchViewModel, LeagueTableItemViewModel leagueTableItem1ViewModel, LeagueTableItemViewModel leagueTableItem2ViewModel, int viewType, DateTime viewDate, int matchCount = 0)
        {
            if (matchViewModel.Team1Ft != null && matchViewModel.Team2Ft != null && matchViewModel.MatchDate <= viewDate.ToEndOfDay())
            {
                switch (Math.Sign((short)matchViewModel.Team1Ft - (short)matchViewModel.Team2Ft))
                {
                case 1:
                    if (leagueTableItem1ViewModel.IsIncluded(true, viewType, matchCount))
                    {
                        leagueTableItem1ViewModel.HomeWins++;
                    }

                    if (leagueTableItem2ViewModel.IsIncluded(false, viewType, matchCount))
                    {
                        leagueTableItem2ViewModel.AwayLosses++;
                    }
                    break;

                case 0:
                    if (leagueTableItem1ViewModel.IsIncluded(true, viewType, matchCount))
                    {
                        leagueTableItem1ViewModel.HomeDraws++;
                    }

                    if (leagueTableItem2ViewModel.IsIncluded(false, viewType, matchCount))
                    {
                        leagueTableItem2ViewModel.AwayDraws++;
                    }
                    break;

                case -1:
                    if (leagueTableItem1ViewModel.IsIncluded(true, viewType, matchCount))
                    {
                        leagueTableItem1ViewModel.HomeLosses++;
                    }

                    if (leagueTableItem2ViewModel.IsIncluded(false, viewType, matchCount))
                    {
                        leagueTableItem2ViewModel.AwayWins++;
                    }
                    break;
                }

                if (leagueTableItem1ViewModel.IsIncluded(true, viewType, matchCount))
                {
                    leagueTableItem1ViewModel.HomeScored   += (int)matchViewModel.Team1Ft;
                    leagueTableItem1ViewModel.HomeConceded += (int)matchViewModel.Team2Ft;
                }

                if (leagueTableItem2ViewModel.IsIncluded(false, viewType, matchCount))
                {
                    leagueTableItem2ViewModel.AwayConceded += (int)matchViewModel.Team1Ft;
                    leagueTableItem2ViewModel.AwayScored   += (int)matchViewModel.Team2Ft;
                }
            }
        }
示例#2
0
        public static List <MatchEventPersonViewModel> GetMatchEventPersonViewModels(this BaseMatchViewModel baseMatchViewModel, bool isTeam1, DateTime viewDate)
        {
            var matchEventPersonViewModels = new List <MatchEventPersonViewModel>();

            var matchEvents = isTeam1
                ? baseMatchViewModel.VersionEntity.MatchEvents.Where(m => m.TeamPrimaryKey == baseMatchViewModel.VersionEntity.Team1Guid && m.MatchEventType != MatchEventType.Started && m.MatchEventType != MatchEventType.Substitute)
                : baseMatchViewModel.VersionEntity.MatchEvents.Where(m => m.TeamPrimaryKey == baseMatchViewModel.VersionEntity.Team2Guid && m.MatchEventType != MatchEventType.Started && m.MatchEventType != MatchEventType.Substitute);

            foreach (var matchEvent in matchEvents)
            {
                MatchEventInRunningType?matchEventInRunningType = null;

                switch (matchEvent.MatchEventType)
                {
                case MatchEventType.Booked:
                    matchEventInRunningType = MatchEventInRunningType.Booked;
                    break;

                case MatchEventType.BroughtOn:
                    matchEventInRunningType = MatchEventInRunningType.BroughtOn;
                    break;

                case MatchEventType.OwnGoal:
                    matchEventInRunningType = MatchEventInRunningType.OwnGoal;
                    break;

                case MatchEventType.Scored:
                    matchEventInRunningType = MatchEventInRunningType.Scored;
                    break;

                case MatchEventType.SentOff:
                    matchEventInRunningType = MatchEventInRunningType.SentOff;
                    break;

                case MatchEventType.TakenOff:
                    matchEventInRunningType = MatchEventInRunningType.TakenOff;
                    break;
                }

                matchEventPersonViewModels.Add(new MatchEventPersonViewModel()
                {
                    PrimaryKey              = matchEvent.PrimaryKey,
                    PersonPrimaryKey        = matchEvent.PersonPrimaryKey,
                    PersonName              = matchEvent.Person.ToViewModel(viewDate).ToString(),
                    MatchEventInRunningType = matchEventInRunningType,
                    Minute = matchEvent.Minute,
                    Extra  = matchEvent.Extra
                });
            }

            matchEventPersonViewModels.Sort();
            return(matchEventPersonViewModels);
        }
示例#3
0
        public static List <MatchPersonViewModel> GetMatchPersonViewModels(this BaseMatchViewModel baseMatchViewModel, Guid teamKey, DateTime viewDate)
        {
            var matchPersonViewModels = new List <MatchPersonViewModel>();

            var campaignMatchVs = baseMatchViewModel.VersionEntity.CampaignStage.MatchVs.Where(m => (m.Team1Guid == teamKey || m.Team2Guid == teamKey)).Where(e => e.IsActive && !e.IsMarkedForDeletion && e.EffectiveFrom <= viewDate && e.EffectiveTo >= viewDate);

            foreach (var campaignMatchV in campaignMatchVs)
            {
                var matchEventVs = campaignMatchV.MatchEvents.Where(m => m.TeamPrimaryKey == teamKey).GroupBy(m => m.PersonPrimaryKey);

                foreach (var matchEventV in matchEventVs)
                {
                    if (!matchPersonViewModels.Any(m => m.PersonGuid == matchEventV.First().PersonPrimaryKey))
                    {
                        var personViewModel = matchEventV.First().Person.ToViewModel(viewDate);

                        MatchEventStartType?matchEventStartType = null;

                        if (baseMatchViewModel.Team1Starters.Any(t => t.Entity.PersonPrimaryKey == personViewModel.HeaderKey) || baseMatchViewModel.Team2Starters.Any(t => t.Entity.PersonPrimaryKey == personViewModel.HeaderKey))
                        {
                            matchEventStartType = MatchEventStartType.Started;
                        }
                        else if (baseMatchViewModel.Team1Substitutes.Any(t => t.Entity.PersonPrimaryKey == personViewModel.HeaderKey) || baseMatchViewModel.Team2Substitutes.Any(t => t.Entity.PersonPrimaryKey == personViewModel.HeaderKey))
                        {
                            matchEventStartType = MatchEventStartType.Substitute;
                        }

                        matchPersonViewModels.Add(new MatchPersonViewModel()
                        {
                            PersonGuid          = personViewModel.HeaderKey,
                            PersonName          = personViewModel.ToString(),
                            PositionType        = matchEventV.First(m => m.MatchEventType == MatchEventType.Started || m.MatchEventType == MatchEventType.Substitute).PositionType,
                            MatchEventStartType = matchEventStartType
                        });
                    }
                }
            }

            matchPersonViewModels.Sort();
            return(matchPersonViewModels);
        }