Ejemplo n.º 1
0
        internal TimelineEventCI(ExportableTimelineEventCI exportable)
        {
            if (exportable == null)
            {
                throw new ArgumentNullException(nameof(exportable));
            }

            Id              = exportable.Id;
            HomeScore       = exportable.HomeScore;
            AwayScore       = exportable.AwayScore;
            MatchTime       = exportable.MatchTime;
            Period          = exportable.Period;
            PeriodName      = exportable.PeriodName;
            Points          = exportable.Points;
            StoppageTime    = exportable.StoppageTime;
            Team            = exportable.Team;
            Type            = exportable.Type;
            Value           = exportable.Value;
            X               = exportable.X;
            Y               = exportable.Y;
            Time            = exportable.Time;
            Assists         = exportable.Assists?.Select(a => new EventPlayerAssistCI(a)).ToList();
            GoalScorer      = exportable.GoalScorer != null ? new EventPlayerCI(exportable.GoalScorer) : null;
            Player          = exportable.Player != null ? new EventPlayerCI(exportable.Player) : null;
            MatchStatusCode = exportable.MatchStatusCode;
            MatchClock      = exportable.MatchClock;
        }
Ejemplo n.º 2
0
        public void Merge(BasicEventDTO dto, CultureInfo culture)
        {
            HomeScore    = dto.HomeScore;
            AwayScore    = dto.AwayScore;
            MatchTime    = dto.MatchTime;
            Period       = dto.Period;
            PeriodName   = dto.PeriodName;
            Points       = dto.Points;
            StoppageTime = dto.StoppageTime;
            Team         = dto.Team;
            Type         = dto.Type;
            Value        = dto.Value;
            X            = dto.X;
            Y            = dto.Y;
            Time         = dto.Time;
            if (dto.Assists != null && dto.Assists.Any())
            {
                if (Assists == null || !Assists.Any())
                {
                    Assists = dto.Assists.Select(s => new EventPlayerAssistCI(s, culture));
                }
                else
                {
                    var newAssists = new List <EventPlayerAssistCI>();
                    foreach (var assist in dto.Assists)
                    {
                        var a = Assists.FirstOrDefault(f => Equals(f.Id, assist.Id));
                        if (a != null && a.Id.Equals(assist.Id))
                        {
                            a.Merge(assist, culture);
                            newAssists.Add(a);
                        }
                        else
                        {
                            newAssists.Add(new EventPlayerAssistCI(assist, culture));
                        }
                    }

                    Assists = newAssists;
                }
            }

            if (dto.GoalScorer != null)
            {
                if (GoalScorer == null)
                {
                    GoalScorer = new EventPlayerCI(dto.GoalScorer, culture);
                }
                else
                {
                    GoalScorer.Merge(dto.GoalScorer, culture);
                }
            }

            if (dto.Player != null)
            {
                if (Player == null)
                {
                    Player = new EventPlayerCI(dto.Player, culture);
                }
                else
                {
                    Player.Merge(dto.Player, culture);
                }
            }

            MatchStatusCode = dto.MatchStatusCode;
            MatchClock      = dto.MatchClock;
        }