Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CompetitorCI"/> class
        /// </summary>
        /// <param name="exportable">A <see cref="ExportableCompetitorCI"/> containing information about the sport entity</param>
        internal void Import(ExportableCompetitorCI exportable)
        {
            Names                = new Dictionary <CultureInfo, string>(exportable.Name);
            _countryNames        = new Dictionary <CultureInfo, string>(exportable.CountryNames);
            _abbreviations       = new Dictionary <CultureInfo, string>(exportable.Abbreviations);
            _associatedPlayerIds = new List <URN>(exportable.AssociatedPlayerIds.Select(URN.Parse));
            _isVirtual           = exportable.IsVirtual;
            _referenceId         = new ReferenceIdCI(exportable.ReferenceIds);
            _jerseys             = new List <JerseyCI>(exportable.Jerseys.Select(j => new JerseyCI(j)));
            _countryCode         = exportable.CountryCode;
            _state               = exportable.State;
            _manager             = exportable.Manager != null ? new ManagerCI(exportable.Manager) : null;
            _venue               = exportable.Venue != null ? new VenueCI(exportable.Venue) : null;
            _gender              = exportable.Gender;
            _ageGroup            = exportable.AgeGroup;
            _fetchedCultures     = new List <CultureInfo>(exportable.FetchedCultures);
            _primaryCulture      = exportable.PrimaryCulture;
            _raceDriverProfile   = exportable.RaceDriverProfile != null ? new RaceDriverProfileCI(exportable.RaceDriverProfile) : null;
            _referenceId         = new ReferenceIdCI(exportable.ReferenceIds);
            _lastTimeCompetitorProfileFetched = DateTime.MinValue;
            if (exportable.LastTimeCompetitorProfileIsFetched.HasValue)
            {
                _lastTimeCompetitorProfileFetched = exportable.LastTimeCompetitorProfileIsFetched.Value;
            }
            if (exportable.CultureCompetitorProfileFetched != null)
            {
                _cultureCompetitorProfileFetched = exportable.CultureCompetitorProfileFetched.ToList();
            }
            _sportId = exportable.SportId != null?URN.Parse(exportable.SportId) : null;

            _categoryId = exportable.CategoryId != null?URN.Parse(exportable.CategoryId) : null;
        }
        /// <summary>
        /// Merges the information from the provided <see cref="CompetitorCI"/> into the current instance
        /// </summary>
        /// <param name="item">A <see cref="CompetitorCI"/> containing information about the competitor</param>
        internal void Merge(CompetitorCI item)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }

            foreach (var k in item.Names.Keys)
            {
                Names[k] = item.Names[k];
            }
            foreach (var k in item._countryNames.Keys)
            {
                _countryNames[k] = item._countryNames[k];
            }
            foreach (var k in item._abbreviations.Keys)
            {
                _abbreviations[k] = item._abbreviations[k];
            }
            _associatedPlayerIds.Clear();
            _associatedPlayerIds.AddRange(item._associatedPlayerIds);
            _isVirtual   = item.IsVirtual;
            _referenceId = item._referenceId ?? _referenceId;
            _jerseys.Clear();
            _jerseys.AddRange(item._jerseys);
            _countryCode       = item._countryCode ?? _countryCode;
            _manager           = item._manager ?? _manager;
            _venue             = item._venue ?? _venue;
            _gender            = item._gender ?? _gender;
            _ageGroup          = item._ageGroup ?? _ageGroup;
            _raceDriverProfile = item._raceDriverProfile ?? _raceDriverProfile;
            _referenceId       = item._referenceId ?? _referenceId;
            _lastTimeCompetitorProfileFetched = item._lastTimeCompetitorProfileFetched;
            _cultureCompetitorProfileFetched  = item._cultureCompetitorProfileFetched?.ToList();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Merges the information from the provided <see cref="CompetitorCI"/> into the current instance
        /// </summary>
        /// <param name="item">A <see cref="CompetitorCI"/> containing information about the competitor</param>
        internal void Merge(CompetitorCI item)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }

            if (!item.Names.IsNullOrEmpty())
            {
                foreach (var k in item.Names.Keys)
                {
                    Names[k] = item.Names[k];
                }
            }

            if (!item._countryNames.IsNullOrEmpty())
            {
                foreach (var k in item._countryNames.Keys)
                {
                    _countryNames[k] = item._countryNames[k];
                }
            }

            if (!item._abbreviations.IsNullOrEmpty())
            {
                foreach (var k in item._abbreviations.Keys)
                {
                    _abbreviations[k] = item._abbreviations[k];
                }
            }

            if (!item._associatedPlayerIds.IsNullOrEmpty())
            {
                _associatedPlayerIds = item._associatedPlayerIds.ToList();
            }
            _isVirtual   = item.IsVirtual;
            _referenceId = item._referenceId ?? _referenceId;
            if (item._jerseys != null && !item._jerseys.IsNullOrEmpty())
            {
                _jerseys = item._jerseys.ToList();
            }
            _countryCode       = item._countryCode ?? _countryCode;
            _state             = item._state ?? _state;
            _manager           = item._manager ?? _manager;
            _venue             = item._venue ?? _venue;
            _gender            = item._gender ?? _gender;
            _ageGroup          = item._ageGroup ?? _ageGroup;
            _raceDriverProfile = item._raceDriverProfile ?? _raceDriverProfile;
            _referenceId       = item._referenceId ?? _referenceId;
            _lastTimeCompetitorProfileFetched = item._lastTimeCompetitorProfileFetched;
            _cultureCompetitorProfileFetched  = item._cultureCompetitorProfileFetched?.ToList();
            _fetchedCultures = item._fetchedCultures;
            _sportId         = item._sportId ?? _sportId;
            _categoryId      = item._categoryId ?? _categoryId;
            if (!string.IsNullOrEmpty(item.ShortName))
            {
                _shortName = item.ShortName;
            }
        }
Exemplo n.º 4
0
        /// <summary>
        ///     Merges the information from the provided <see cref="CompetitorProfileDTO" /> into the current instance
        /// </summary>
        /// <param name="competitorProfile">A <see cref="CompetitorProfileDTO" /> containing information about the competitor</param>
        /// <param name="culture">A <see cref="CultureInfo" /> specifying the language of the passed <code>dto</code></param>
        internal void Merge(CompetitorProfileDTO competitorProfile, CultureInfo culture)
        {
            Contract.Requires(competitorProfile != null);
            Contract.Requires(competitorProfile.Competitor != null);

            _isVirtual              = competitorProfile.Competitor.IsVirtual;
            Names[culture]          = competitorProfile.Competitor.Name;
            _countryNames[culture]  = competitorProfile.Competitor.CountryName;
            _abbreviations[culture] = string.IsNullOrEmpty(competitorProfile.Competitor.Abbreviation)
                ? SdkInfo.GetAbbreviationFromName(competitorProfile.Competitor.Name)
                : competitorProfile.Competitor.Abbreviation;
            ReferenceId =
                UpdateReferenceIds(competitorProfile.Competitor.Id, competitorProfile.Competitor.ReferenceIds);
            _countryCode = competitorProfile.Competitor.CountryCode;

            if (competitorProfile.Players != null && competitorProfile.Players.Any())
            {
                _associatedPlayerIds.Clear();
                _associatedPlayerIds.AddRange(competitorProfile.Players.Select(s => s.Id));
            }

            if (competitorProfile.Jerseys != null && competitorProfile.Jerseys.Any())
            {
                _jerseys.Clear();
                _jerseys.AddRange(competitorProfile.Jerseys.Select(s => new JerseyCI(s)));
            }

            if (competitorProfile.Manager != null)
            {
                if (_manager == null)
                {
                    _manager = new ManagerCI(competitorProfile.Manager, culture);
                }
                else
                {
                    _manager.Merge(competitorProfile.Manager, culture);
                }
            }

            if (competitorProfile.Venue != null)
            {
                if (_venue == null)
                {
                    _venue = new VenueCI(competitorProfile.Venue, culture);
                }
                else
                {
                    _venue.Merge(competitorProfile.Venue, culture);
                }
            }

            if (!string.IsNullOrEmpty(competitorProfile.Competitor.Gender))
            {
                _gender = competitorProfile.Competitor.Gender;
            }

            ((List <CultureInfo>)_fetchedCultures).Add(culture);
        }
Exemplo n.º 5
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="SportEntityCI" /> class
 /// </summary>
 /// <param name="originalCompetitorCI">A <see cref="CompetitorCI" /> containing information about the sport entity</param>
 protected CompetitorCI(CompetitorCI originalCompetitorCI)
     : base(new SportEntityDTO(originalCompetitorCI.Id.ToString(), ""))
 {
     Names                = originalCompetitorCI.Names;
     _countryNames        = originalCompetitorCI._countryNames;
     _abbreviations       = originalCompetitorCI._abbreviations;
     _associatedPlayerIds = originalCompetitorCI._associatedPlayerIds;
     _isVirtual           = originalCompetitorCI._isVirtual;
     ReferenceId          = originalCompetitorCI.ReferenceId;
     _jerseys             = originalCompetitorCI._jerseys;
     _countryCode         = originalCompetitorCI._countryCode;
     _manager             = originalCompetitorCI._manager;
     _venue               = originalCompetitorCI._venue;
     _gender              = originalCompetitorCI._gender;
     _fetchedCultures     = originalCompetitorCI._fetchedCultures;
     _dataRouterManager   = originalCompetitorCI._dataRouterManager;
     _primaryCulture      = originalCompetitorCI._primaryCulture;
 }
Exemplo n.º 6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CompetitorCI"/> class
        /// </summary>
        /// <param name="exportable">A <see cref="ExportableCompetitorCI"/> containing information about the sport entity</param>
        internal void Import(ExportableCompetitorCI exportable)
        {
            try
            {
                Names                = exportable.Name.IsNullOrEmpty() ? new Dictionary <CultureInfo, string>() : new Dictionary <CultureInfo, string>(exportable.Name);
                _countryNames        = exportable.CountryNames.IsNullOrEmpty() ? new Dictionary <CultureInfo, string>() : new Dictionary <CultureInfo, string>(exportable.CountryNames);
                _abbreviations       = exportable.Abbreviations.IsNullOrEmpty() ? new Dictionary <CultureInfo, string>() : new Dictionary <CultureInfo, string>(exportable.Abbreviations);
                _associatedPlayerIds = exportable.AssociatedPlayerIds.IsNullOrEmpty() ? new List <URN>() : new List <URN>(exportable.AssociatedPlayerIds.Select(URN.Parse));
                _isVirtual           = exportable.IsVirtual;
                _referenceId         = exportable.ReferenceIds.IsNullOrEmpty() ? null : new ReferenceIdCI(exportable.ReferenceIds);
                _jerseys             = exportable.Jerseys.IsNullOrEmpty() ? new List <JerseyCI>() : new List <JerseyCI>(exportable.Jerseys.Select(j => new JerseyCI(j)));
                _countryCode         = exportable.CountryCode;
                _state               = exportable.State;
                _manager             = exportable.Manager == null ? null : new ManagerCI(exportable.Manager);
                _venue               = exportable.Venue == null ? null : new VenueCI(exportable.Venue);
                _gender              = exportable.Gender;
                _ageGroup            = exportable.AgeGroup;
                _fetchedCultures     = exportable.FetchedCultures.IsNullOrEmpty() ? new List <CultureInfo>() : new List <CultureInfo>(exportable.FetchedCultures);
                _primaryCulture      = exportable.PrimaryCulture;
                _raceDriverProfile   = exportable.RaceDriverProfile == null ? null : new RaceDriverProfileCI(exportable.RaceDriverProfile);
                _referenceId         = exportable.ReferenceIds.IsNullOrEmpty() ? null : new ReferenceIdCI(exportable.ReferenceIds);
                _lastTimeCompetitorProfileFetched = DateTime.MinValue;
                if (exportable.LastTimeCompetitorProfileIsFetched.HasValue)
                {
                    _lastTimeCompetitorProfileFetched = exportable.LastTimeCompetitorProfileIsFetched.Value;
                }
                _cultureCompetitorProfileFetched = new List <CultureInfo>();
                if (exportable.CultureCompetitorProfileFetched != null)
                {
                    _cultureCompetitorProfileFetched = exportable.CultureCompetitorProfileFetched.ToList();
                }
                _sportId = exportable.SportId != null?URN.Parse(exportable.SportId) : null;

                _categoryId = exportable.CategoryId != null?URN.Parse(exportable.CategoryId) : null;

                _shortName = exportable.ShortName;
            }
            catch (Exception e)
            {
                SdkLoggerFactory.GetLoggerForExecution(typeof(CompetitorCI)).Error("Importing CompetitorCI", e);
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SportEntityCI"/> class
 /// </summary>
 /// <param name="originalCompetitorCI">A <see cref="CompetitorCI"/> containing information about the sport entity</param>
 protected CompetitorCI(CompetitorCI originalCompetitorCI)
     : base(new SportEntityDTO(originalCompetitorCI.Id.ToString(), ""))
 {
     Names                = originalCompetitorCI.Names;
     _countryNames        = originalCompetitorCI._countryNames;
     _abbreviations       = originalCompetitorCI._abbreviations;
     _associatedPlayerIds = originalCompetitorCI._associatedPlayerIds;
     _isVirtual           = originalCompetitorCI._isVirtual;
     _referenceId         = originalCompetitorCI._referenceId;
     _jerseys             = originalCompetitorCI._jerseys;
     _countryCode         = originalCompetitorCI._countryCode;
     _state               = originalCompetitorCI._state;
     _manager             = originalCompetitorCI._manager;
     _venue               = originalCompetitorCI._venue;
     _gender              = originalCompetitorCI._gender;
     _ageGroup            = originalCompetitorCI._ageGroup;
     _fetchedCultures     = originalCompetitorCI._fetchedCultures;
     _dataRouterManager   = originalCompetitorCI._dataRouterManager;
     _primaryCulture      = originalCompetitorCI._primaryCulture;
     _raceDriverProfile   = originalCompetitorCI._raceDriverProfile;
     _lastTimeCompetitorProfileFetched = originalCompetitorCI._lastTimeCompetitorProfileFetched;
     _cultureCompetitorProfileFetched  = originalCompetitorCI._cultureCompetitorProfileFetched;
 }
Exemplo n.º 8
0
        /// <summary>
        /// Merges the information from the provided <see cref="CompetitorProfileDTO"/> into the current instance
        /// </summary>
        /// <param name="competitorProfile">A <see cref="CompetitorProfileDTO"/> containing information about the competitor</param>
        /// <param name="culture">A <see cref="CultureInfo"/> specifying the language of the passed <code>dto</code></param>
        internal void Merge(CompetitorProfileDTO competitorProfile, CultureInfo culture)
        {
            Guard.Argument(competitorProfile, nameof(competitorProfile)).NotNull();
            Guard.Argument(competitorProfile.Competitor, nameof(competitorProfile.Competitor)).NotNull();

            _isVirtual              = competitorProfile.Competitor.IsVirtual;
            Names[culture]          = competitorProfile.Competitor.Name;
            _countryNames[culture]  = competitorProfile.Competitor.CountryName;
            _abbreviations[culture] = string.IsNullOrEmpty(competitorProfile.Competitor.Abbreviation)
                ? SdkInfo.GetAbbreviationFromName(competitorProfile.Competitor.Name)
                : competitorProfile.Competitor.Abbreviation;
            _referenceId =
                UpdateReferenceIds(competitorProfile.Competitor.Id, competitorProfile.Competitor.ReferenceIds);
            _countryCode = competitorProfile.Competitor.CountryCode;
            _state       = competitorProfile.Competitor.State;

            if (competitorProfile.Players != null && competitorProfile.Players.Any())
            {
                _associatedPlayerIds.Clear();
                _associatedPlayerIds.AddRange(competitorProfile.Players.Select(s => s.Id));
            }

            if (competitorProfile.Jerseys != null && competitorProfile.Jerseys.Any())
            {
                _jerseys.Clear();
                _jerseys.AddRange(competitorProfile.Jerseys.Select(s => new JerseyCI(s)));
            }

            if (competitorProfile.Manager != null)
            {
                if (_manager == null)
                {
                    _manager = new ManagerCI(competitorProfile.Manager, culture);
                }
                else
                {
                    _manager.Merge(competitorProfile.Manager, culture);
                }
            }

            if (competitorProfile.Venue != null)
            {
                if (_venue == null)
                {
                    _venue = new VenueCI(competitorProfile.Venue, culture);
                }
                else
                {
                    _venue.Merge(competitorProfile.Venue, culture);
                }
            }
            if (!string.IsNullOrEmpty(competitorProfile.Competitor.Gender))
            {
                _gender = competitorProfile.Competitor.Gender;
            }

            if (!string.IsNullOrEmpty(competitorProfile.Competitor.AgeGroup))
            {
                _ageGroup = competitorProfile.Competitor.AgeGroup;
            }

            if (competitorProfile.RaceDriverProfile != null)
            {
                _raceDriverProfile = new RaceDriverProfileCI(competitorProfile.RaceDriverProfile);
            }

            if (competitorProfile.Players != null && competitorProfile.Players.Any())
            {
                _lastTimeCompetitorProfileFetched = DateTime.Now;
                _cultureCompetitorProfileFetched.Add(culture);
            }
            if (competitorProfile.Competitor.SportId != null)
            {
                _sportId = competitorProfile.Competitor.SportId;
            }

            if (competitorProfile.Competitor.CategoryId != null)
            {
                _categoryId = competitorProfile.Competitor.CategoryId;
            }


            ((List <CultureInfo>)_fetchedCultures).Add(culture);
        }