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); }
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); }
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); }
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; }
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); }
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); }
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); }
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); }
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); }