/// <summary> /// Asynchronously gets a list of active <see cref="IEnumerable{ISportEvent}"/> /// </summary> /// <remarks>Lists all <see cref="ISportEvent"/> that are cached. (once schedule is loaded)</remarks> /// <param name="culture">A <see cref="CultureInfo"/> specifying the language or a null reference to use the languages specified in the configuration</param> /// <returns>A <see cref="Task{T}"/> representing the async operation</returns> public async Task <IEnumerable <ISportEvent> > GetActiveTournamentsAsync(CultureInfo culture = null) { LogInt.Info($"Invoked GetActiveTournamentsAsync: Culture={culture}."); var cul = culture ?? _defaultCultures.First(); await _sportDataCache.LoadAllTournamentsForAllSportsAsync().ConfigureAwait(false); // to be sure all tournaments for all sports are fetched var tours = await _sportEventCache.GetActiveTournamentsAsync(cul).ConfigureAwait(false); return(tours?.Select(t => _sportEntityFactory.BuildSportEvent <ISportEvent>(t.Id, t.GetSportIdAsync().Result, new[] { cul }, _exceptionStrategy))); }
/// <summary> /// Asynchronously gets a list of active <see cref="IEnumerable{ISportEvent}"/> /// </summary> /// <remarks>Lists all <see cref="ISportEvent"/> that are cached. (once schedule is loaded)</remarks> /// <param name="culture">A <see cref="CultureInfo"/> specifying the language or a null reference to use the languages specified in the configuration</param> /// <returns>A <see cref="Task{T}"/> representing the async operation</returns> public async Task <IEnumerable <ISportEvent> > GetActiveTournamentsAsync(CultureInfo culture = null) { var cul = culture ?? _defaultCultures.First(); LogInt.LogInformation($"Invoked GetActiveTournamentsAsync: [Culture={cul.TwoLetterISOLanguageName}]"); try { await _sportDataCache.LoadAllTournamentsForAllSportsAsync().ConfigureAwait(false); var tours = await _sportEventCache.GetActiveTournamentsAsync(cul).ConfigureAwait(false); return(tours?.Select(t => _sportEntityFactory.BuildSportEvent <ISportEvent>(t.Id, t.GetSportIdAsync().Result, new[] { cul }, _exceptionStrategy))); } catch (Exception e) { LogInt.LogError(e, $"Error executing GetActiveTournamentsAsync: [Culture={cul.TwoLetterISOLanguageName}]"); if (_exceptionStrategy == ExceptionHandlingStrategy.THROW) { throw; } return(null); } }