/// <summary> /// Asynchronous export item's properties /// </summary> /// <returns>An <see cref="ExportableCI"/> instance containing all relevant properties</returns> public Task <ExportableGroupCI> ExportAsync() { var cr = new Dictionary <string, string>(); if (!CompetitorsReferences.IsNullOrEmpty()) { foreach (var competitorsReference in CompetitorsReferences) { try { if (!competitorsReference.Value.ReferenceIds.IsNullOrEmpty()) { var refs = string.Join(",", competitorsReference.Value.ReferenceIds.Select(s => $"{s.Key}={s.Value}")); cr.Add(competitorsReference.Key.ToString(), refs); } } catch (Exception e) { SdkLoggerFactory.GetLoggerForExecution(typeof(GroupCI)).Error("Exporting GroupCI", e); } } } return(Task.FromResult(new ExportableGroupCI { Id = Id, Name = Name, Competitors = CompetitorsIds?.Select(s => s.ToString()).ToList(), CompetitorsReferences = cr.IsNullOrEmpty() ? null : cr })); }
/// <summary> /// Asynchronous export item's properties /// </summary> /// <returns>An <see cref="ExportableCI"/> instance containing all relevant properties</returns> public Task <ExportableGroupCI> ExportAsync() { var cr = new Dictionary <string, Dictionary <string, string> >(); if (!CompetitorsReferences.IsNullOrEmpty()) { foreach (var competitorsReference in CompetitorsReferences) { try { var refs = competitorsReference.Value.ReferenceIds?.ToDictionary(r => r.Key, r => r.Value); cr.Add(competitorsReference.Key.ToString(), refs); } catch (Exception e) { SdkLoggerFactory.GetLoggerForExecution(typeof(GroupCI)).LogError(e, "Exporting GroupCI"); } } } return(Task.FromResult(new ExportableGroupCI { Id = Id, Name = Name, Competitors = CompetitorsIds?.Select(s => s.ToString()), CompetitorsReferences = cr.IsNullOrEmpty() ? null : cr })); }
/// <summary> /// Asynchronous export item's properties /// </summary> /// <returns>An <see cref="ExportableCI"/> instance containing all relevant properties</returns> public async Task <ExportableGroupCI> ExportAsync() { return(new ExportableGroupCI { Id = Id, Name = Name, Competitors = CompetitorsIds?.Select(s => s.ToString()), CompetitorsReferences = CompetitorsReferences?.ToDictionary(c => c.Key.ToString(), c => c.Value.ReferenceIds.ToDictionary(r => r.Key, r => r.Value)) }); }
/// <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)); 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 = CompetitorsIds?.Select(s => s.ToString()), Schedule = Schedule?.Select(s => s.ToString()).ToList() }); }