Exemple #1
0
        /// <summary>
        /// Asynchronous export item's properties
        /// </summary>
        /// <returns>An <see cref="ExportableCI"/> instance containing all relevant properties</returns>
        public async Task <ExportableCurrentSeasonInfoCI> ExportAsync()
        {
            var groupsTask      = Groups?.Select(async g => await g.ExportAsync().ConfigureAwait(false));
            var competitorsTask = Competitors?.Select(async c => await c.ExportAsync().ConfigureAwait(false) as ExportableCompetitorCI);

            return(new ExportableCurrentSeasonInfoCI
            {
                Id = Id.ToString(),
                Name = new Dictionary <CultureInfo, string>(Name),
                Year = Year,
                StartDate = StartDate,
                EndDate = EndDate,
                SeasonCoverage = SeasonCoverage != null ? await SeasonCoverage.ExportAsync().ConfigureAwait(false) : null,
                Groups = groupsTask != null ? await Task.WhenAll(groupsTask) : null,
                CurrentRound = CurrentRound != null ? await CurrentRound.ExportAsync().ConfigureAwait(false) : null,
                Competitors = competitorsTask != null ? await Task.WhenAll(competitorsTask) : null,
                Schedule = Schedule?.Select(s => s.ToString()).ToList()
            });
        }
Exemple #2
0
        /// <summary>
        /// Asynchronous export item's properties
        /// </summary>
        /// <returns>An <see cref="ExportableCI"/> instance containing all relevant properties</returns>
        public async Task <ExportableCurrentSeasonInfoCI> ExportAsync()
        {
            var groupsTasks = Groups?.Select(async g => await g.ExportAsync().ConfigureAwait(false)).ToList();

            if (!groupsTasks.IsNullOrEmpty())
            {
                await Task.WhenAll(groupsTasks).ConfigureAwait(false);
            }

            return(new ExportableCurrentSeasonInfoCI
            {
                Id = Id.ToString(),
                Name = new Dictionary <CultureInfo, string>(Name),
                Year = Year,
                StartDate = StartDate,
                EndDate = EndDate,
                SeasonCoverage = SeasonCoverage != null ? await SeasonCoverage.ExportAsync().ConfigureAwait(false) : null,
                Groups = groupsTasks.IsNullOrEmpty() ? null : groupsTasks.Select(s => s.Result).ToList(),
                CurrentRound = CurrentRound != null ? await CurrentRound.ExportAsync().ConfigureAwait(false) : null,
                Competitors = CompetitorsIds?.Select(s => s.ToString()).ToList(),
                Schedule = Schedule?.Select(s => s.ToString()).ToList()
            });
        }