public IEnumerable <ITransmitterCommand> Adapt( MessageContext <Schedule> messageContext, Language language, LineService lineService ) { var message = messageContext.Message; if (language == Language.English) { foreach (var evnt in message.SportEvents.Where(x => x.Tournament != null)) { if (evnt.Competitors.Count == 2 && evnt.Competitors[0].Qualifier == evnt.Competitors[1].Qualifier) { continue; } var sport = SportIdToSportConverter.Convert(evnt.Tournament.Sport.Id); if (sport == null) { logger.LogWarning( $"Unknown sportId={evnt.Tournament.Sport.Id} in ScheduleMessage. EventId={evnt.Id}"); continue; } yield return(new CreateUpdateGameEventMetaCommand( lineService: lineService, gameEventId: evnt.Id.ToTransmitterEventId(), receivedOn: messageContext.ReceivedOn, incomingId: messageContext.IncomingId, gameEventType: GameEventType.Match, gameEventStartDateUtc: evnt.Scheduled, sport: sport, categoryId: evnt.Tournament.Category.Id, topicId: evnt.Tournament.Id, competitors: GetCompetitors(evnt), extraAttributes: null )); } } var translations = GetTranslations(message, language); if (translations.IsEmpty) { yield break; } yield return(new AddTranslationsCommand ( lineService: lineService, receivedOn: messageContext.ReceivedOn, incomingId: messageContext.IncomingId, translations: translations )); }
public IEnumerable <ITransmitterCommand> Adapt( MessageContext <Fixture> messageContext, Language language, LineService lineService ) { var message = messageContext.Message; var sport = SportIdToSportConverter.Convert(message.Tournament.Sport.Id); if (sport == null) { logger.LogWarning($"Unknown sportId={message.Tournament.Sport.Id} in FixtureMessage Id={message.Id} Liveodds={message.Liveodds}"); yield break; } if (language == Language.English) { ImmutableDictionary <string, string> extraAttributes = null; if (message.Liveodds != null) { var dic = new Dictionary <string, string> { { "Booked", message.Liveodds == "booked" ? "1" : "0" } }; var keys = new string[] { "period_length", "overtime_length", "best_of", "best_of_legs", "set_limit" }; foreach (var key in keys) { if (message.ExtraInfo.TryGetValue(key, out var value)) { dic.Add(key, value); } } extraAttributes = dic.ToImmutableDictionary(); } yield return(new CreateUpdateGameEventMetaCommand ( lineService: lineService, gameEventId: message.Id.ToTransmitterEventId(), receivedOn: messageContext.ReceivedOn, incomingId: messageContext.IncomingId, gameEventType: GameEventType.Match, gameEventStartDateUtc: message.StartTime, sport: sport, categoryId: message.Tournament.Category.Id, topicId: message.Tournament.Id, competitors: GetCompetitors(message), extraAttributes: extraAttributes )); } var translations = GetTranslations(message, language); if (translations.IsEmpty) { yield break; } yield return(new AddTranslationsCommand ( lineService: lineService, receivedOn: messageContext.ReceivedOn, incomingId: messageContext.IncomingId, translations: translations )); }