Beispiel #1
0
        internal MarketMappingDTO(variant_mappingsMapping mapping)
        {
            Guard.Argument(mapping, nameof(mapping)).NotNull();
            Guard.Argument(mapping.product_id, nameof(mapping.product_id)).Positive();
            Guard.Argument(mapping.sport_id, nameof(mapping.sport_id)).NotNull().NotEmpty();
            Guard.Argument(mapping.market_id, nameof(mapping.market_id)).NotNull().NotEmpty();

            ProducerIds = string.IsNullOrEmpty(mapping.product_ids)
                ? new[] { mapping.product_id }
                : mapping.product_ids.Split(new[] { SdkInfo.MarketMappingProductsDelimiter }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse);
            SportId     = mapping.sport_id == "all" ? null : URN.Parse(mapping.sport_id);
            OrgMarketId = mapping.market_id;
            var marketId = string.IsNullOrEmpty(mapping.product_market_id)
                               ? mapping.market_id.Split(':')
                               : mapping.product_market_id.Split(':');
            int typeId;

            int.TryParse(marketId[0], out typeId);
            MarketTypeId = typeId;
            if (marketId.Length == 2)
            {
                int subTypeId;
                MarketSubTypeId = int.TryParse(marketId[1], out subTypeId) ? subTypeId : (int?)null;
            }
            SovTemplate = mapping.sov_template;
            ValidFor    = mapping.valid_for;

            OutcomeMappings = new List <OutcomeMappingDTO>();
            if (mapping.mapping_outcome != null)
            {
                OutcomeMappings = mapping.mapping_outcome.Select(o => new OutcomeMappingDTO(o, string.IsNullOrEmpty(mapping.product_market_id) ? mapping.market_id : mapping.product_market_id));
            }
        }
Beispiel #2
0
        internal MarketMappingDTO(variant_mappingsMapping mapping)
        {
            Contract.Requires(mapping != null);
            Contract.Requires(mapping.product_id > 0);
            Contract.Requires(!string.IsNullOrEmpty(mapping.sport_id));
            Contract.Requires(!string.IsNullOrEmpty(mapping.market_id));

            ProducerId  = mapping.product_id;
            ProducerIds = string.IsNullOrEmpty(mapping.product_ids)
                ? new[] { mapping.product_id }
                : mapping.product_ids.Split(new[] { SdkInfo.MarketMappingProductsDelimiter }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse);
            SportId     = mapping.sport_id == "all" ? null : URN.Parse(mapping.sport_id);
            OrgMarketId = mapping.market_id;
            var marketId = string.IsNullOrEmpty(mapping.product_market_id)
                               ? mapping.market_id.Split(':')
                               : mapping.product_market_id.Split(':');
            int typeId;

            int.TryParse(marketId[0], out typeId);
            MarketTypeId = typeId;
            if (marketId.Length == 2)
            {
                int subTypeId;
                MarketSubTypeId = int.TryParse(marketId[1], out subTypeId) ? subTypeId : (int?)null;
            }
            SovTemplate = mapping.sov_template;
            ValidFor    = mapping.valid_for;

            if (mapping.mapping_outcome != null)
            {
                OutcomeMappings = mapping.mapping_outcome.Select(o => new OutcomeMappingDTO(o, mapping.market_id));
            }
        }