Example #1
0
        public static IEnumerable<Odds> GetOdds()
        {
            var today = DateTime.Today.ToString("M/d/yyyy");
            var query = "http://asiwebservices.heritagesports.eu:8080/feeds/dannylinesfeed_json.asp?usr=usatoday&pwd=13dT34ty8&startdate=" + today;
            var result = new WebClient().DownloadString(query);
            var json = JObject.Parse(result);

            var leagues = json["lines"]["leagues"].Select(l => JsonConvert.DeserializeObject<League>(l.ToString()));
            var odds = new List<Odds>();
            foreach (var league in leagues)
                foreach (var game in league.Games)
                {
                    var odd = new Odds()
                    {
                        Date = DateTime.ParseExact(game.Date.Replace("PDT ", ""), "ddd MMM d HH:mm:ss yyyy", CultureInfo.CurrentUICulture),
                        FavoriteTeamName = HttpUtility.UrlDecode(game.Teams.First(team => team.IsFavorite == "1").Name),
                        UnderdogTeamName = HttpUtility.UrlDecode(game.Teams.First(team => team.IsFavorite != "1").Name),
                        HomeTeamName = HttpUtility.UrlDecode(game.Teams.First(team => team.IsHome == "1").Name),
                        SportName = HttpUtility.UrlDecode(league.Name),
                        TotalPoints = JsonConvert.DeserializeObject<double>(game.Total == "" ? "NaN" : game.Total.Replace("%26frac12%3B", ".5")),
                        PointSpread = JsonConvert.DeserializeObject<double>(game.Total == "" ? "NaN" : game.Total.Replace("%26frac12%3B", ".5")),
                    };

                    odds.Add(odd);
                }

            return odds;
        }
Example #2
0
 public OddsViewModel(Odds odd)
 {
     Model = odd;
 }