예제 #1
0
        public IEnumerable <OddViewModel> GetSingleTennisOdds(DateTime date, TennisFixtureViewModel fixture)
        {
            var oddsSources =
                this.bookmakerRepository
                .GetActiveOddsSources()
                .ToList();

            var allOdds     = new List <OddsForEvent>();
            var playerAOdds = new List <OddsForEvent>();
            var playerBOdds = new List <OddsForEvent>();

            foreach (var oddsSource in oddsSources)
            {
                var oddsForEvent =
                    this.linqStoredProcedureRepository
                    .GetLatestOddsForEvent(date,
                                           oddsSource.Source,
                                           fixture.PlayerASurname,
                                           fixture.PlayerBSurname,
                                           fixture.PlayerAFirstName,
                                           fixture.PlayerBFirstName)
                    .ToList();

                playerAOdds.AddRange(oddsForEvent.Where(x => x.Outcome == "Home Win"));
                playerBOdds.AddRange(oddsForEvent.Where(x => x.Outcome == "Away Win"));
            }

            allOdds.AddRange(playerAOdds.Where(x => x.DecimalOdd == playerAOdds.Max(m => m.DecimalOdd)).OrderBy(x => (50 - x.OddsSource.Length) + ((x.OddsSource.Length % 2) * 10)).Take(1));
            allOdds.AddRange(playerBOdds.Where(x => x.DecimalOdd == playerBOdds.Max(m => m.DecimalOdd)).OrderBy(x => (50 - x.OddsSource.Length) + ((x.OddsSource.Length % 2) * 10)).Take(1));

            var ret = Mapper.Map <IEnumerable <OddsForEvent>, IEnumerable <OddViewModel> >(allOdds).ToList();

            ret.ForEach(x =>
            {
                x.MatchId = fixture.Id;
                x.Sport   = this.sport;
            });

            return(ret);
        }
예제 #2
0
    public IEnumerable<OddViewModel> GetSingleTennisOdds(DateTime date, TennisFixtureViewModel fixture)
    {
      var oddsSources =
        this.bookmakerRepository
            .GetActiveOddsSources()
            .ToList();

      var allOdds = new List<OddsForEvent>();
      var playerAOdds = new List<OddsForEvent>();
      var playerBOdds = new List<OddsForEvent>();

      foreach (var oddsSource in oddsSources)
      {
        var oddsForEvent =
          this.linqStoredProcedureRepository
              .GetLatestOddsForEvent(date,
                                     oddsSource.Source,
                                     fixture.PlayerASurname,
                                     fixture.PlayerBSurname,
                                     fixture.PlayerAFirstName,
                                     fixture.PlayerBFirstName)
              .ToList();

        playerAOdds.AddRange(oddsForEvent.Where(x => x.Outcome == "Home Win"));
        playerBOdds.AddRange(oddsForEvent.Where(x => x.Outcome == "Away Win"));
      }

      allOdds.AddRange(playerAOdds.Where(x => x.DecimalOdd == playerAOdds.Max(m => m.DecimalOdd)).OrderBy(x => (50 - x.OddsSource.Length) + ((x.OddsSource.Length % 2) * 10)).Take(1));
      allOdds.AddRange(playerBOdds.Where(x => x.DecimalOdd == playerBOdds.Max(m => m.DecimalOdd)).OrderBy(x => (50 - x.OddsSource.Length) + ((x.OddsSource.Length % 2) * 10)).Take(1));

      var ret = Mapper.Map<IEnumerable<OddsForEvent>, IEnumerable<OddViewModel>>(allOdds).ToList();
      ret.ForEach(x =>
      {
        x.MatchId = fixture.Id;
        x.Sport = this.sport;
      });

      return ret;
    }