private void TriggerOutcome(IOutcomeDefinition outcomeDefinition, TrackingEventData data, HttpContext context) { if (outcomeDefinition == null) { BadRequest("Please provide a valid outcome ID", context); return; } if (data.OutcomeCurrency == null) { BadRequest("Please provide a currency", context); return; } decimal value = 0.0m; decimal.TryParse(data.OutcomeValue, out value); if (data.OutcomeType == "interaction") { Tracker.Current.Interaction.RegisterOutcome(outcomeDefinition, data.OutcomeCurrency, value); return; } Tracker.Current.CurrentPage.RegisterOutcome(outcomeDefinition, data.OutcomeCurrency, value); }
/// <summary>Initializes a new instance of the <see cref="OutcomeSettlement" /> class</summary> /// <param name="deadHeatFactor">a dead-head factor for the current <see cref="IOutcomeSettlement" /> instance.</param> /// <param name="id">the value uniquely identifying the current <see cref="IOutcomeSettlement" /></param> /// <param name="result">a value indicating whether the outcome associated with current <see cref="IOutcomeSettlement" /> is winning</param> /// <param name="voidFactor">the <see cref="VoidFactor" /> associated with a current <see cref="IOutcomeSettlement" /> or a null reference</param> /// <param name="nameProvider">A <see cref="INameProvider"/> used to generate the outcome name(s)</param> /// <param name="mappingProvider">A <see cref="IMarketMappingProvider"/> instance used for providing mapping ids of markets and outcomes</param> /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}"/> specifying languages the current instance supports</param> /// <param name="outcomeDefinition">The associated <see cref="IOutcomeDefinition"/></param> internal OutcomeSettlement(double?deadHeatFactor, string id, int result, VoidFactor?voidFactor, INameProvider nameProvider, IMarketMappingProvider mappingProvider, IEnumerable <CultureInfo> cultures, IOutcomeDefinition outcomeDefinition) : base(id, nameProvider, mappingProvider, cultures, outcomeDefinition) { DeadHeatFactor = deadHeatFactor; Result = result == 1; VoidFactor = voidFactor; switch (result) { case 0: OutcomeResult = OutcomeResult.Lost; break; case 1: OutcomeResult = OutcomeResult.Won; break; default: OutcomeResult = OutcomeResult.UndecidedYet; break; } }
private string GetOutcomeGroup(IOutcomeDefinition outcome) { if (outcome?.OutcomeGroupUri == null) return null; var outcomeGroupTaxonomyManager = TaxonomyManager.Provider.GetOutcomeGroupManager(); var outcomeGroup = outcomeGroupTaxonomyManager.GetOutcomeGroup(outcome.OutcomeGroupUri, Context.Language.CultureInfo); return outcomeGroup == null ? null : outcomeGroupTaxonomyManager.GetFullName(outcomeGroup.Uri, "/"); }
private string GetOutcomeGroup(IOutcomeDefinition outcome) { if (outcome?.Id == null) { return(null); } var outcomeGroup = this.outcomeGroupTaxonomyManager.GetOutcomeGroup(outcome.OutcomeGroupUri, Context.Language.CultureInfo); return(outcomeGroup == null ? null : this.outcomeGroupTaxonomyManager.GetFullName(outcomeGroup.Uri, "/")); }
/// <summary> /// Initializes a new instance of the <see cref="Outcome" /> class /// </summary> /// <param name="id">the value uniquely identifying the current <see cref="Outcome" /> instance</param> /// <param name="nameProvider">A <see cref="INameProvider"/> used to generate the outcome name(s)</param> /// <param name="mappingProvider">A <see cref="IMarketMappingProvider"/> instance used for providing mapping ids of markets and outcomes</param> /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}"/> specifying languages the current instance supports</param> /// <param name="outcomeDefinition"></param> protected Outcome(string id, INameProvider nameProvider, IMarketMappingProvider mappingProvider, IEnumerable <CultureInfo> cultures, IOutcomeDefinition outcomeDefinition) { Guard.Argument(nameProvider, nameof(nameProvider)).NotNull(); Guard.Argument(cultures, nameof(cultures)).NotNull().NotEmpty(); Id = id; _nameProvider = nameProvider; _mappingProvider = mappingProvider; _cultures = cultures; OutcomeDefinition = outcomeDefinition; }
/// <summary> /// Initializes a new instance of the <see cref="OutcomeOdds" /> class /// </summary> /// <param name="id">the value uniquely identifying the current <see cref="OutcomeOdds" /> instance</param> /// <param name="active">A value indicating whether the current <see cref="OutcomeOdds" /> is active - i.e. should bets on it be accepted </param> /// <param name="odds">the odds for the current <see cref="OutcomeOdds" /> instance</param> /// <param name="probabilities">the probabilities for the current <see cref="OutcomeOdds" /> instance</param> /// <param name="nameProvider">A <see cref="INameProvider"/> used to generate the outcome name(s)</param> /// <param name="mappingProvider">A <see cref="IMarketMappingProvider"/> instance used for providing mapping ids of markets and outcomes</param> /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}"/> specifying languages the current instance supports</param> /// <param name="outcomeDefinition">The associated <see cref="IOutcomeDefinition"/></param> internal OutcomeOdds(string id, bool?active, double odds, double?probabilities, INameProvider nameProvider, IMarketMappingProvider mappingProvider, IEnumerable <CultureInfo> cultures, IOutcomeDefinition outcomeDefinition) : base(id, active, probabilities, nameProvider, mappingProvider, cultures, outcomeDefinition) { Odds = odds; }
/// <summary> /// Initializes a new instance of the <see cref="Outcome" /> class /// </summary> /// <param name="id">the value uniquely identifying the current <see cref="Outcome" /> instance</param> /// <param name="nameProvider">A <see cref="INameProvider"/> used to generate the outcome name(s)</param> /// <param name="mappingProvider">A <see cref="IMarketMappingProvider"/> instance used for providing mapping ids of markets and outcomes</param> /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}"/> specifying languages the current instance supports</param> /// <param name="outcomeDefinition"></param> protected Outcome(string id, INameProvider nameProvider, IMarketMappingProvider mappingProvider, IEnumerable <CultureInfo> cultures, IOutcomeDefinition outcomeDefinition) { Contract.Requires(nameProvider != null); Contract.Requires(cultures != null); Contract.Requires(cultures.Any()); Id = id; _nameProvider = nameProvider; _mappingProvider = mappingProvider; _cultures = cultures; OutcomeDefinition = outcomeDefinition; }
private string WriteOutcomeDefinition(IOutcomeDefinition outcomeDefinition, CultureInfo culture) { try { return($"NameTemplate[{culture.TwoLetterISOLanguageName}]:{outcomeDefinition?.GetNameTemplate(culture)}"); } catch (Exception e) { _log.LogWarning(e.Message, e); } return(null); }
/// <summary>Initializes a new instance of the <see cref="OutcomeSettlement" /> class</summary> /// <param name="deadHeatFactor">a dead-head factor for the current <see cref="IOutcomeSettlement" /> instance.</param> /// <param name="id">the value uniquely identifying the current <see cref="IOutcomeSettlement" /></param> /// <param name="result">a value indicating whether the outcome associated with current <see cref="IOutcomeSettlement" /> is winning</param> /// <param name="voidFactor">the <see cref="VoidFactor" /> associated with a current <see cref="IOutcomeSettlement" /> or a null reference</param> /// <param name="nameProvider">A <see cref="INameProvider"/> used to generate the outcome name(s)</param> /// <param name="mappingProvider">A <see cref="IMarketMappingProvider"/> instance used for providing mapping ids of markets and outcomes</param> /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}"/> specifying languages the current instance supports</param> /// <param name="outcomeDefinition">The associated <see cref="IOutcomeDefinition"/></param> internal OutcomeSettlement(double?deadHeatFactor, string id, bool result, VoidFactor?voidFactor, INameProvider nameProvider, IMarketMappingProvider mappingProvider, IEnumerable <CultureInfo> cultures, IOutcomeDefinition outcomeDefinition) : base(id, nameProvider, mappingProvider, cultures, outcomeDefinition) { DeadHeatFactor = deadHeatFactor; Result = result; VoidFactor = voidFactor; }
/// <summary>Initializes a new instance of the <see cref="OutcomeProbabilities" /> class</summary> /// <param name="id">The value uniquely identifying the current <see cref="OutcomeProbabilities" /> instance</param> /// <param name="active">A value indicating whether the current <see cref="OutcomeProbabilities" /> is active - i.e. should bets on it be accepted /// </param> /// <param name="probabilities">The probabilities for the current <see cref="OutcomeProbabilities" /> instance</param> /// <param name="nameProvider">A <see cref="INameProvider"/> used to generate the outcome name(s)</param> /// <param name="mappingProvider">A <see cref="IMarketMappingProvider"/> instance used for providing mapping ids of markets and outcomes</param> /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}"/> specifying languages the current instance supports</param> /// <param name="outcomeDefinition">The associated <see cref="IOutcomeDefinition"/></param> /// <param name="additionalProbabilities">Additional probability attributes for markets which potentially will be (partly) refunded</param> internal OutcomeProbabilities(string id, bool?active, double?probabilities, INameProvider nameProvider, IMarketMappingProvider mappingProvider, IEnumerable <CultureInfo> cultures, IOutcomeDefinition outcomeDefinition, IAdditionalProbabilities additionalProbabilities) : base(id, nameProvider, mappingProvider, cultures, outcomeDefinition) { Active = active; Probabilities = probabilities; AdditionalProbabilities = additionalProbabilities; }
/// <summary> /// Initializes a new instance of the <see cref="Outcome" /> class /// </summary> /// <param name="id">the value uniquely identifying the current <see cref="Outcome" /> instance</param> /// <param name="nameProvider">A <see cref="INameProvider"/> used to generate the outcome name(s)</param> /// <param name="mappingProvider">A <see cref="IMarketMappingProvider"/> instance used for providing mapping ids of markets and outcomes</param> /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}"/> specifying languages the current instance supports</param> /// <param name="outcomeDefinition">An outcome definition</param> protected Outcome(string id, INameProvider nameProvider, IMarketMappingProvider mappingProvider, IEnumerable <CultureInfo> cultures, IOutcomeDefinition outcomeDefinition) { Guard.Argument(nameProvider, nameof(nameProvider)).NotNull(); Guard.Argument(cultures, nameof(cultures)).NotNull(); if (!cultures.Any()) { throw new ArgumentOutOfRangeException(nameof(cultures)); } Id = id; _nameProvider = nameProvider; _mappingProvider = mappingProvider; _cultures = cultures; OutcomeDefinition = outcomeDefinition; }
/// <summary> /// Initializes a new instance of the <see cref="PlayerOutcomeOdds" /> class /// </summary> /// <param name="id">the value uniquely identifying the current <see cref="PlayerOutcomeOdds" /> instance</param> /// <param name="active"> /// a value indicating whether the current <see cref="OutcomeOdds" /> is active - i.e. should bets on /// it be accepted /// </param> /// <param name="odds">the odds for the current <see cref="OutcomeOdds" /> instance</param> /// <param name="probabilities">the probabilities for the current <see cref="OutcomeOdds" /> instance</param> /// <param name="nameProvider">A <see cref="INameProvider"/> used to generate the outcome name(s)</param> /// <param name="mappingProvider">A <see cref="IMarketMappingProvider"/> instance used for providing mapping ids of markets and outcomes</param> /// <param name="match">A <see cref="IMatch"/> representing the the match associated with the outcome / market</param> /// <param name="teamFlag">A value indicating whether the player is associated with home or away team - 1 : HomeTeam, 2 : AwayTeam</param> /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}"/> specifying languages the current instance supports</param> /// <param name="outcomeDefinition">The associated <see cref="IOutcomeDefinition"/></param> internal PlayerOutcomeOdds(string id, bool?active, double odds, double?probabilities, INameProvider nameProvider, IMarketMappingProvider mappingProvider, IMatch match, int teamFlag, IEnumerable <CultureInfo> cultures, IOutcomeDefinition outcomeDefinition) : base(id, active, odds, probabilities, nameProvider, mappingProvider, cultures, outcomeDefinition) { Contract.Requires(match != null); Contract.Requires(teamFlag >= 1 && teamFlag <= 2); _teamFlag = teamFlag; _match = match; }
/// <summary> /// Initializes a new instance of the <see cref="PlayerOutcomeOdds" /> class /// </summary> /// <param name="id">the value uniquely identifying the current <see cref="PlayerOutcomeOdds" /> instance</param> /// <param name="active"> /// a value indicating whether the current <see cref="OutcomeOdds" /> is active - i.e. should bets on /// it be accepted /// </param> /// <param name="odds">the odds for the current <see cref="OutcomeOdds" /> instance</param> /// <param name="probabilities">the probabilities for the current <see cref="OutcomeOdds" /> instance</param> /// <param name="nameProvider">A <see cref="INameProvider"/> used to generate the outcome name(s)</param> /// <param name="mappingProvider">A <see cref="IMarketMappingProvider"/> instance used for providing mapping ids of markets and outcomes</param> /// <param name="match">A <see cref="IMatch"/> representing the match associated with the outcome / market</param> /// <param name="teamFlag">A value indicating whether the player is associated with home or away team - 1 : HomeTeam, 2 : AwayTeam</param> /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}"/> specifying languages the current instance supports</param> /// <param name="outcomeDefinition">The associated <see cref="IOutcomeDefinition"/></param> /// <param name="additionalProbabilities">Additional probability attributes for markets which potentially will be (partly) refunded</param> internal PlayerOutcomeOdds(string id, bool?active, double odds, double?probabilities, INameProvider nameProvider, IMarketMappingProvider mappingProvider, IMatch match, int teamFlag, IEnumerable <CultureInfo> cultures, IOutcomeDefinition outcomeDefinition, IAdditionalProbabilities additionalProbabilities) : base(id, active, odds, probabilities, nameProvider, mappingProvider, cultures, outcomeDefinition, additionalProbabilities) { Guard.Argument(match, nameof(match)).NotNull(); Guard.Argument(teamFlag, nameof(teamFlag)).InRange(1, 2); _teamFlag = teamFlag; _match = match; }
/// <summary>Initializes a new instance of the <see cref="OutcomeSettlement" /> class</summary> /// <param name="deadHeatFactor">a dead-head factor for the current <see cref="IOutcomeSettlement" /> instance.</param> /// <param name="id">the value uniquely identifying the current <see cref="IOutcomeSettlement" /></param> /// <param name="result">a value indicating whether the outcome associated with current <see cref="IOutcomeSettlement" /> is winning</param> /// <param name="voidFactor">the <see cref="VoidFactor" /> associated with a current <see cref="IOutcomeSettlement" /> or a null reference</param> /// <param name="nameProvider">A <see cref="INameProvider"/> used to generate the outcome name(s)</param> /// <param name="mappingProvider">A <see cref="IMarketMappingProvider"/> instance used for providing mapping ids of markets and outcomes</param> /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}"/> specifying languages the current instance supports</param> /// <param name="outcomeDefinition">The associated <see cref="IOutcomeDefinition"/></param> internal OutcomeSettlement(double?deadHeatFactor, string id, int result, VoidFactor?voidFactor, INameProvider nameProvider, IMarketMappingProvider mappingProvider, IEnumerable <CultureInfo> cultures, IOutcomeDefinition outcomeDefinition) : base(id, nameProvider, mappingProvider, cultures, outcomeDefinition) { DeadHeatFactor = deadHeatFactor; Result = result == 1; VoidFactor = voidFactor; OutcomeResult = result switch { 0 => OutcomeResult.Lost, 1 => OutcomeResult.Won, _ => OutcomeResult.UndecidedYet }; }
/// <summary> /// Gets the new <see cref="IOutcomeOdds"/> instances /// </summary> /// <param name="sportEvent">The <see cref="ISportEvent"/> associated with the market</param> /// <param name="nameProvider">The <see cref="INameProvider"/> used to generate outcome name</param> /// <param name="mappingProvider">The <see cref="IMarketMappingProvider"/> used to provide market mapping</param> /// <param name="outcome">The <see cref="oddsChangeMarketOutcome"/> representing the outcome to be mapped</param> /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}"/> specifying languages the current instance supports</param> /// <param name="outcomeDefinition">The associated <see cref="IOutcomeDefinition"/></param> /// <returns>IOutcomeOdds</returns> protected virtual IOutcomeOdds GetOutcomeWithOdds(ISportEvent sportEvent, INameProvider nameProvider, IMarketMappingProvider mappingProvider, oddsChangeMarketOutcome outcome, IEnumerable <CultureInfo> cultures, IOutcomeDefinition outcomeDefinition) { var isValidPlayerOutcome = false; IMatch match = null; if (outcome.teamSpecified) { match = sportEvent as IMatch; isValidPlayerOutcome = !(match == null || outcome.team < 1 || outcome.team > 2); } if (isValidPlayerOutcome) { return(new PlayerOutcomeOdds(outcome.id, outcome.activeSpecified ? (bool?)(outcome.active != 0) : null, outcome.odds, outcome.probabilitiesSpecified ? (double?)outcome.probabilities : null, nameProvider, mappingProvider, match, outcome.team, cultures, outcomeDefinition, GetAdditionalProbabilities(outcome))); } return(new OutcomeOdds(outcome.id, outcome.activeSpecified ? (bool?)(outcome.active != 0) : null, outcome.odds, outcome.probabilitiesSpecified ? (double?)outcome.probabilities : null, nameProvider, mappingProvider, cultures, outcomeDefinition, GetAdditionalProbabilities(outcome))); }
private string WriteOutcomeDefinition(IOutcomeDefinition outcomeDefinition, CultureInfo culture) { return($"NameTemplate[{culture.TwoLetterISOLanguageName}]:{outcomeDefinition?.GetNameTemplate(culture)}"); }
public void TrackOutcome_ValidOutcome_ShouldRegisterOutcome([Frozen] Guid outcomeDefinitionId, TrackerService trackerService, ITracker tracker, Contact contact, IOutcomeDefinition outcome) { // Arrange tracker.IsActive.Returns(true); tracker.Contact.Returns(contact); trackerService.OutcomeDefinitionManager.Get(Arg.Any <Guid>(), Arg.Any <CultureInfo>()).Returns(info => { outcome.Id.Returns((Guid)info[0]); return(outcome); }); using (new TrackerSwitcher(tracker)) { // Act trackerService.TrackOutcome(outcomeDefinitionId); // Assert tracker.CurrentPage.Received(1).RegisterOutcome(Arg.Is <IOutcomeDefinition>(x => x.Id == outcomeDefinitionId), Arg.Any <string>(), Arg.Any <decimal>()); } }