コード例 #1
0
        public IEnumerable <EntityLinkProtocolViewModel> GetMainSquad(Side side)
        {
            IEnumerable <ProtocolRecord> main = protocolManager.GetMainPlayers(GetTeamId(side));
            IEnumerable <ProtocolRecord> subs = protocolManager.GetSubstitutions(GetTeamId(side));

            var protocolData = new List <EntityLinkProtocolViewModel>();

            foreach (ProtocolRecord pr in main)
            {
                if (pr.personId > 0)
                {
                    var el = new EntityLinkProtocolViewModel();

                    el.main = new EntityLinkViewModel()
                    {
                        id    = pr.personId.ToString(),
                        text  = GetPersonName(pr.personId.Value),
                        title = GetPersonName(pr.personId.Value)
                    };

                    protocolModelUtils.CalculateMinutes(pr, el);
                    el.info = GetEventName(pr.eventId);

                    AddSubstatution(el, subs);

                    protocolData.Add(el);
                }
            }

            return(protocolData);
        }
コード例 #2
0
        private EntityLinkProtocolViewModel GetEntityLinkProtocol(ProtocolRecord protocolRecord)
        {
            EntityLinkProtocolViewModel entityLink = null;

            if (protocolRecord.personId > 0)
            {
                entityLink = new EntityLinkProtocolViewModel();

                entityLink.main = new EntityLinkViewModel()
                {
                    id    = protocolRecord.personId.ToString(),
                    text  = GetPersonName(protocolRecord.personId.Value),
                    title = GetPersonName(protocolRecord.personId.Value)
                };

                protocolModelUtils.CalculateMinutes(protocolRecord, entityLink);
                entityLink.info = GetEventName(protocolRecord.eventId);

                if (protocolRecord.CustomIntValue.HasValue)
                {
                    entityLink.extra = new EntityLinkProtocolViewModel()
                    {
                        main = new EntityLinkViewModel()
                        {
                            id    = protocolRecord.CustomIntValue.ToString(),
                            text  = GetPersonName(protocolRecord.CustomIntValue.Value),
                            title = GetPersonName(protocolRecord.CustomIntValue.Value)
                        }
                    };
                }
            }

            return(entityLink);
        }
コード例 #3
0
        public IEnumerable <EntityLinkProtocolViewModel> GetReserve(Side side)
        {
            IEnumerable <FakeProtocolSubViewModel> reserve = side == Side.Home
                ? gameNoteBuilder?.FakeProtocol?.home?.reserve ?? new FakeProtocolSubViewModel[0]
                : gameNoteBuilder?.FakeProtocol?.away?.reserve ?? new FakeProtocolSubViewModel[0];

            var protocolData = new List <EntityLinkProtocolViewModel>();

            foreach (FakeProtocolSubViewModel fakeRecord in reserve)
            {
                EntityLinkProtocolViewModel entityLink = null;

                if (!string.IsNullOrWhiteSpace(fakeRecord.name))
                {
                    entityLink = new EntityLinkProtocolViewModel()
                    {
                        main = new EntityLinkViewModel()
                        {
                            id    = string.Empty,
                            text  = fakeRecord.name,
                            title = fakeRecord.name
                        }
                    };
                }

                if (entityLink != null)
                {
                    protocolData.Add(entityLink);
                }
            }

            return(protocolData);
        }
コード例 #4
0
        public void CalculateMinutes(FakeProtocolEventViewModel record, EntityLinkProtocolViewModel model)
        {
            if (!record.extraTime)
            {
                model.minute      = record.minute;
                model.extraMinute = null;
                return;
            }

            model.minute      = record.minute.HasValue ? gameFormatManager.GetRoundTime(record.minute.Value) : record.minute;
            model.extraMinute = model.minute.HasValue ? record.minute.Value - model.minute.Value : (int?)null;
        }
コード例 #5
0
        private IEnumerable <EntityLinkProtocolViewModel> GetEntityLinkProtocol(IEnumerable <FakeProtocolEventViewModel> fakeRecords, bool infoFromEvent = false)
        {
            var protocolData = new List <EntityLinkProtocolViewModel>();

            foreach (FakeProtocolEventViewModel fr in fakeRecords)
            {
                EntityLinkProtocolViewModel el = GetEntityLinkProtocol(fr, infoFromEvent);
                if (el != null)
                {
                    protocolData.Add(el);
                }
            }

            return(protocolData);
        }
コード例 #6
0
        public IEnumerable <EntityLinkProtocolViewModel> GetGoals(Side side)
        {
            IEnumerable <ProtocolRecord> goals = protocolManager.GetGoals(GetTeamId(side));

            var protocolData = new List <EntityLinkProtocolViewModel>();

            foreach (ProtocolRecord pr in goals)
            {
                EntityLinkProtocolViewModel el = GetEntityLinkProtocol(pr);
                if (el != null)
                {
                    protocolData.Add(el);
                }
            }

            return(protocolData);
        }
コード例 #7
0
        public IEnumerable <EntityLinkProtocolViewModel> GetReserve(Side side)
        {
            IEnumerable <ProtocolRecord> subs    = protocolManager.GetSubstitutions(GetTeamId(side));
            IEnumerable <ProtocolRecord> reserve = protocolManager.GetReservePlayers(GetTeamId(side));

            var protocolData = new List <EntityLinkProtocolViewModel>();

            foreach (ProtocolRecord pr in reserve)
            {
                // don't duplicate players who will shown in main stuff as sub
                if (!subs.Any(r => r.personId == pr.personId))
                {
                    EntityLinkProtocolViewModel el = GetEntityLinkProtocol(pr);
                    if (el != null)
                    {
                        protocolData.Add(el);
                    }
                }
            }

            return(protocolData);
        }
コード例 #8
0
        private void AddSubstatution(EntityLinkProtocolViewModel record, IEnumerable <ProtocolRecord> subs)
        {
            ProtocolRecord sub = subs.FirstOrDefault(s => s.CustomIntValue == int.Parse(record.main.id));

            if (sub == null || !sub.CustomIntValue.HasValue)
            {
                return;
            }

            record.extra = new EntityLinkProtocolViewModel()
            {
                main = new EntityLinkViewModel()
                {
                    id    = sub.personId.ToString(),
                    text  = GetPersonName(sub.personId.Value),
                    title = GetPersonName(sub.personId.Value)
                }
            };

            protocolModelUtils.CalculateMinutes(sub, record.extra);

            AddSubstatution(record.extra, subs);
        }
コード例 #9
0
        private EntityLinkProtocolViewModel GetEntityLinkProtocol(FakeProtocolEventViewModel protocolRecord, bool infoFromEvent = false)
        {
            EntityLinkProtocolViewModel entityLink = null;

            if (!string.IsNullOrWhiteSpace(protocolRecord.name))
            {
                entityLink = new EntityLinkProtocolViewModel();

                entityLink.main = new EntityLinkViewModel()
                {
                    id    = string.Empty,
                    text  = protocolRecord.name,
                    title = protocolRecord.name
                };

                entityLink.info = infoFromEvent && protocolRecord.eventId > 0 ? GetEventName(protocolRecord.eventId) : protocolRecord.info;
                entityLink.data = protocolRecord.data;

                protocolModelUtils.CalculateMinutes(protocolRecord, entityLink);
            }

            return(entityLink);
        }