/// <summary>
        /// Get schedule as an asynchronous operation
        /// </summary>
        /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}" /> specifying the languages to which the returned instance should be translated</param>
        /// <returns>A <see cref="Task{TResult}" /> representing an async operation</returns>
        public async Task <IEnumerable <URN> > GetScheduleAsync(IEnumerable <CultureInfo> cultures)
        {
            var missingCultures = LanguageHelper.GetMissingCultures(cultures, _loadedSchedules).ToList();

            if (_scheduleUrns == null && missingCultures.Any())
            {
                var tasks = missingCultures.Select(s => DataRouterManager.GetSportEventsForTournamentAsync(Id, s, this)).ToList();
                await Task.WhenAll(tasks).ConfigureAwait(false);

                if (tasks.All(a => a.IsCompleted))
                {
                    _loadedSchedules.AddRange(missingCultures);
                    if (tasks.First().Result != null)
                    {
                        _scheduleUrns = tasks.First().Result.Select(s => s.Item1);
                    }
                }
            }

            if (_scheduleUrns.IsNullOrEmpty() && _currentSeasonInfo != null)
            {
                _scheduleUrns = _currentSeasonInfo.Schedule;
            }

            return(_scheduleUrns);
        }
예제 #2
0
        /// <summary>
        /// get stages as an asynchronous operation.
        /// </summary>
        /// <param name="cultures">The cultures</param>
        /// <returns>A <see cref="Task{T}" /> representing the asynchronous operation</returns>
        public async Task <IEnumerable <URN> > GetStagesAsync(IEnumerable <CultureInfo> cultures)
        {
            if (_childStages != null)
            {
                return(_childStages);
            }
            await FetchMissingSummary(new[] { DefaultCulture }, false).ConfigureAwait(false);

            if (_childStages == null && !_stageScheduleFetched)
            {
                try
                {
                    _stageScheduleFetched = true;
                    var results = await DataRouterManager.GetSportEventsForTournamentAsync(Id, DefaultCulture, this).ConfigureAwait(false);

                    if (!results.IsNullOrEmpty())
                    {
                        _childStages = new ReadOnlyCollection <URN>(results.Select(r => r.Item1).ToList());
                    }
                }
                catch
                {
                }
            }

            return(_childStages);
        }