Exemple #1
0
 /// <summary>
 /// Sets the <see cref="IBetBonus" />
 /// </summary>
 /// <param name="value">The quantity multiplied by 10000 and rounded to a long value</param>
 /// <param name="betBonusMode">The bet bonus mode</param>
 /// <param name="betBonusType">Type of the bet bonus</param>
 /// <returns>Returns a <see cref="IBetBuilder" /></returns>
 public IBetBuilder SetBetBonus(long value, BetBonusMode betBonusMode = BetBonusMode.All, BetBonusType betBonusType = BetBonusType.Total)
 {
     if (!(value > 0 && value < 1000000000000000000))
     {
         throw new ArgumentException("BetBonus value not valid. Must be greater then zero.");
     }
     _betBonus = new BetBonus(value, betBonusType, betBonusMode);
     return(this);
 }
Exemple #2
0
        public Bet(IBetBonus bonus, IStake stake, IStake entireStake, string id, IEnumerable <int> selectedSystems, IEnumerable <ISelection> selections, string reofferRefId, long sumOfWins, bool?customBet, int?calculationOdds)
        {
            Guard.Argument(stake, nameof(stake)).NotNull();
            Guard.Argument(id, nameof(id)).Require(string.IsNullOrEmpty(id) || TicketHelper.ValidateTicketId(id));
            var systems = selectedSystems == null ? new List <int>() : selectedSystems.ToList();

            Guard.Argument(systems, nameof(systems)).Require(selectedSystems == null ||
                                                             (systems.Any()
                                                              //&& systems.Count < 64
                                                              && systems.Count == systems.Distinct().Count() &&
                                                              systems.All(a => a > 0)));
            var listSelections = selections.ToList();

            Guard.Argument(listSelections, nameof(listSelections)).NotNull();
            if (!listSelections.Any())
            {
                throw new ArgumentOutOfRangeException(nameof(selections));
            }
            Guard.Argument(listSelections, nameof(listSelections)).Require(/*listSelections.Count < 64 && */ listSelections.Count == listSelections.Distinct().Count());

            Guard.Argument(reofferRefId, nameof(reofferRefId)).Require(string.IsNullOrEmpty(reofferRefId) || reofferRefId.Length <= 50);
            Guard.Argument(sumOfWins, nameof(sumOfWins)).NotNegative();
            bool customBetBool = customBet ?? false;

            Guard.Argument(customBet, nameof(customBet)).Require((customBetBool && calculationOdds != null && calculationOdds >= 0) || (!customBetBool && calculationOdds == null));

            Bonus           = bonus;
            Stake           = stake;
            EntireStake     = entireStake;
            Id              = id;
            SelectedSystems = systems;
            Selections      = listSelections;
            ReofferRefId    = reofferRefId;
            SumOfWins       = sumOfWins;
            CustomBet       = customBet;
            CalculationOdds = calculationOdds;

            if (SelectedSystems != null)
            {
                var enumerable = SelectedSystems as IList <int> ?? SelectedSystems.ToList();
                if (SelectedSystems != null && enumerable.Any(a => a > Selections.Count()))
                {
                    throw new ArgumentException("Invalid value in SelectedSystems.");
                }
            }
        }
Exemple #3
0
 public Bonus(IBetBonus bonus)
 {
     _value = bonus.Value;
     _type  = MtsTicketHelper.Convert(bonus.Type);
     _mode  = MtsTicketHelper.Convert(bonus.Mode);
 }