Beispiel #1
0
        public ActionResult UpdateMatchOdd(MatchOdd matchOdd)
        {
            try
            {
                using (var db = new Context())
                {
                    var dbmatchodd = db.MatchOdds.FirstOrDefault(x => x.ID == matchOdd.ID);
                    if (dbmatchodd != null)
                    {
                        dbmatchodd.MatchId   = matchOdd.MatchId;
                        dbmatchodd.Specifier = matchOdd.Specifier;
                        dbmatchodd.Odd       = matchOdd.Odd;

                        db.SaveChanges();
                        return(StatusCode(StatusCodes.Status200OK));
                    }
                    else
                    {
                        return(StatusCode(StatusCodes.Status400BadRequest, "you have to provide a valid id"));
                    }
                }
            }
            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
            }
        }
Beispiel #2
0
        public async Task <MatchOdd> UpdateMatchOdds(MatchOdd updatedMatchOdd)
        {
            var matchOdd = await GetMatchOddsById(updatedMatchOdd.ID);

            _db.MatchOdds.Attach(matchOdd);
            _db.Entry(matchOdd).State = EntityState.Modified;
            await _db.SaveChangesAsync();

            return(matchOdd);
        }
Beispiel #3
0
 public async Task <IActionResult> UpdateMatch([FromBody] MatchOdd matchOdd)
 {
     try
     {
         return(Ok(await _service.UpdateMatchOdds(matchOdd)));
     }
     catch (Exception ex)
     {
         return(StatusCode(500, ex.InnerException.Message));
     }
 }
Beispiel #4
0
        public async Task <int> CreateMatchOdds(MatchOdd matchOdd)
        {
            var mtch = new MatchOdd
            {
                MatchId   = matchOdd.ID,
                Odd       = matchOdd.Odd,
                Specifier = matchOdd.Specifier
            };

            await _db.MatchOdds.AddAsync(mtch);

            await _db.SaveChangesAsync();

            return(mtch.MatchId);
        }
Beispiel #5
0
        public Response <bool> BetOverUnder(Account account, MatchOdd odd)
        {
            Response <bool> res = new Response <bool>();

            res.Data = false;
            if (odd == null || (odd != null && odd.OddType != 3 && odd.OddType != 9))
            {
                return(res);
            }
            try
            {
                SbobetTicket ticket = new SbobetTicket();
                //Request
                ticket.MatchOddId = odd.OddId;
                ticket.HdpType    = odd.HdpType;                   //Live =2 , today=1
                ticket.Op         = account.Choose == 0? "h": "a"; //Over
                if (account.Choose == 0)
                {
                    ticket.Odds = odd.OddType == 3 ? odd.o : odd.o1; //Home , Over =h , Away, Under = a
                }
                else if (account.Choose == 1)
                {
                    ticket.Odds = odd.OddType == 3 ? odd.u : odd.u1; //Home , Over =h , Away, Under = a
                }
                ticket.IsLive  = 0;
                ticket.IsOr    = 0;
                ticket.BetPage = 18;//check
                ticket.Style   = 1;

                //Confirm
                ticket.SameTicket  = 0;
                ticket.Betcount    = 0;
                ticket.Stake       = account.Stake;//Maxbet
                ticket.StakeInAuto = account.Stake;
                ticket.AcceptIfAny = 1;
                ticket.AutoProcess = 0;
                ticket.AutoRefresh = 0;  //check
                ticket.TimeDiff    = 6735;

                return(Bet(account, ticket));
            }
            catch (Exception ex)
            {
                res.Errors.Add("Bet Sbobet Errors: " + ex.Message);
                return(res);
            }
        }
Beispiel #6
0
        public ActionResult AddMatchOdd(MatchOdd matchodd)
        {
            try
            {
                using (var db = new Context())
                {
                    db.MatchOdds.Add(matchodd);
                    db.SaveChanges();

                    return(StatusCode(StatusCodes.Status200OK, new { matchoddid = matchodd.ID }));
                }
            }
            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, e.Message + " " + e.InnerException.Message));
            }
        }
        public async Task <PostMatch> InsertMatchWithOdd(PostMatch model)
        {
            using var transaction = _dbcontext.Database.BeginTransaction(IsolationLevel.ReadCommitted);

            try
            {
                Match match = new Match
                {
                    Description = model.Description,
                    MatchDate   = model.MatchDate,
                    MatchTime   = model.MatchTime,
                    TeamA       = model.TeamA,
                    TeamB       = model.TeamB,
                    Sport       = model.Sport
                };

                _dbcontext.Matches.Add(match);
                await _dbcontext.SaveChangesAsync();

                MatchOdd odd = new MatchOdd
                {
                    MatchId   = match.Id,
                    Specifier = model.Specifier,
                    Odd       = model.Odd
                };

                _dbcontext.MatchOdds.Add(odd);
                await _dbcontext.SaveChangesAsync();

                transaction.Commit();

                return(model);
            }
            catch (Exception e)
            {
                transaction.Rollback();
                return(null);
            }
            finally
            {
                transaction.Dispose();
            }
        }
Beispiel #8
0
 private void addTable(MatchOdd _data)
 {
     try
     {
         Program._dtMatch.Rows.Add(new object[] {
             _data.Match.MatchId,
             _data.Match.Contest,
             _data.Match.Home,
             _data.Match.Away,
             _data.OddTypeDisplay,
             _data.Goal,
             _data.OddType == 3? _data.o: _data.OddType == 9?_data.o1:0,
             _data.OddType == 3? _data.u: _data.OddType == 9?_data.u1:0
         });
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #9
0
        public Response <List <MatchOdd> > EarlyOdds(string s)
        {
            Response <List <MatchOdd> > res = new Response <List <MatchOdd> >();
            List <Match>    matchs          = new List <Match>();
            List <MatchOdd> odds            = new List <MatchOdd>();

            res.Data = odds;
            try
            {
                s = s.Replace("\\u200C", "");
                if (s.Length < 100)
                {
                    return(res);
                }
                var m = s.Replace("\\u200C", "").Split(new string[1] {
                    "]],[[",
                }, StringSplitOptions.None);

                var m1 = m[1].Replace("[", "").Split(new string[1] {
                    "],",
                }, StringSplitOptions.None);
                foreach (var item in m1)
                {
                    var   k     = item.Split(',');
                    Match match = new Match();
                    match.MatchId   = int.Parse(k[0]);
                    match.ContestId = int.Parse(k[2]);
                    match.Home      = k[3].Replace("'", "");
                    match.Away      = k[4].Replace("'", "");
                    match.MatchOdds = new List <MatchOdd>();
                    matchs.Add(match);
                }

                var m0 = m[0].Substring(m[0].IndexOf("[[[") + 3, m[0].Length - (m[0].IndexOf("[[[") + 3)).Split(new string[1] {
                    "],[",
                }, StringSplitOptions.None);
                foreach (var item in m0)
                {
                    var k = item.Split(',');
                    foreach (var match in matchs.Where(x => x.ContestId == int.Parse(k[0])))
                    {
                        match.Contest = k[1].Replace("'", "");
                    }
                }

                var m2 = m[2].Replace("[", "").Split(new string[1] {
                    "]],,,"
                }, StringSplitOptions.None);
                var m20 = m2[0].Split(new string[1] {
                    "],"
                }, StringSplitOptions.None);
                foreach (var item in m20)
                {
                    var   k     = item.Split(',');
                    Match match = matchs.SingleOrDefault(x => x.MatchId == int.Parse(k[1]));
                    if (match != null)
                    {
                        match.MatchNumber = int.Parse(k[0]);
                    }
                }

                var m3 = m2[1].Split(new string[1] {
                    "]],"
                }, StringSplitOptions.None);
                foreach (var item in m3)
                {
                    var   k     = item.Replace("[", "").Replace("]", "").Split(',');
                    Match match = matchs.SingleOrDefault(x => x.MatchNumber == int.Parse(k[1]));
                    if (match != null)
                    {
                        MatchOdd odd;
                        odd                = new MatchOdd();
                        odd.Match          = match;
                        odd.MatchId        = match.MatchId;
                        odd.OddId          = int.Parse(k[0]);
                        odd.Goal           = double.Parse(k[5]);
                        odd.OddType        = int.Parse(k[2]);
                        odd.OddTypeDisplay = odd.OddType == 1 ? "H" : odd.OddType == 3 ? "H" : odd.OddType == 7 ? "H1" : odd.OddType == 9 ? "H1" : "";
                        odd.HdpType        = 0; //Early
                        switch (k[2])
                        {
                        case "1":
                            odd.h = double.Parse(k[6]);
                            odd.a = double.Parse(k[7]);
                            break;

                        case "3":
                            odd.o = double.Parse(k[6]);
                            odd.u = double.Parse(k[7]);
                            break;

                        case "7":
                            odd.h1 = double.Parse(k[6]);
                            odd.a1 = double.Parse(k[7]);
                            break;

                        case "9":
                            odd.o1 = double.Parse(k[6]);
                            odd.u1 = double.Parse(k[7]);
                            break;
                        }
                        odds.Add(odd);
                    }
                }
                res.Data = odds;
            }
            catch (Exception ex)
            {
                res.Errors.Add("Convert Sbobet Today Odds Errors: " + ex.Message);
                res.Data = odds;
            }
            return(res);
        }
Beispiel #10
0
        public Response <List <MatchOdd> > RunningOdds(string s)
        {
            Response <List <MatchOdd> > res = new Response <List <MatchOdd> >();
            List <Match>    matchs          = new List <Match>();
            List <MatchOdd> odds            = new List <MatchOdd>();

            res.Data = odds;
            try
            {
                s = s.Replace("\\u200C", "");
                if (s.Length < 100)
                {
                    return(res);
                }
                var m = s.Replace("\\u200C", "").Split(new string[1] {
                    "]],[[",
                }, StringSplitOptions.None);
                var m1 = m[1].Replace("[", "").Split(new string[1] {
                    "],",
                }, StringSplitOptions.None);
                foreach (var item in m1)
                {
                    var   k     = item.Split(',');
                    Match match = new Match();
                    match.MatchId   = int.Parse(k[0]);
                    match.ContestId = int.Parse(k[2]);
                    match.Home      = k[3];
                    match.Away      = k[4];
                    match.MatchOdds = new List <MatchOdd>();
                    matchs.Add(match);
                }

                var m2 = m[2].Replace("[", "").Split(new string[1] {
                    "],",
                }, StringSplitOptions.None);
                foreach (var item in m2)
                {
                    var   k     = item.Split(',');
                    Match match = matchs.SingleOrDefault(x => x.MatchId == int.Parse(k[1]) && k[2] == "0");
                    if (match != null)
                    {
                        match.MatchNumber = int.Parse(k[0]);
                    }
                }

                var md = m[3].Split(new string[1] {
                    "]],,[[",
                }, StringSplitOptions.None)[0];
                var md1 = md.Split(new string[1] {
                    "],["
                }, StringSplitOptions.None);
                foreach (var item in md1)
                {
                    var   k     = item.Split(',');
                    Match match = matchs.SingleOrDefault(x => x.MatchNumber == int.Parse(k[0]));
                    if (match != null)
                    {
                        match.Period = int.Parse(k[2]);
                        match.Minute = int.Parse(k[3]);
                    }
                }

                var m3 = m[3].Split(new string[1] {
                    "]],,[[",
                }, StringSplitOptions.None)[1];
                var m31 = m3.Split(new string[1] {
                    "]],["
                }, StringSplitOptions.None);
                foreach (var item in m31)
                {
                    var   k     = item.Replace("[", "").Replace("]", "").Split(',');
                    Match match = matchs.SingleOrDefault(x => x.MatchNumber == int.Parse(k[1]));
                    if (match != null)
                    {
                        MatchOdd odd;
                        odd                = new MatchOdd();
                        odd.Match          = match;
                        odd.MatchId        = match.MatchId;
                        odd.OddId          = int.Parse(k[0]);
                        odd.Goal           = Double.Parse(k[5]);
                        odd.OddType        = int.Parse(k[2]);
                        odd.OddTypeDisplay = odd.OddType == 1 ? "H" : odd.OddType == 3 ? "H" : odd.OddType == 7 ? "H1" : odd.OddType == 9 ? "H1" : "";
                        odd.HdpType        = 2; //Live
                        switch (k[2])
                        {
                        case "1":
                            odd.h = double.Parse(k[6]);
                            odd.a = double.Parse(k[7]);
                            break;

                        case "3":
                            odd.o = double.Parse(k[6]);
                            odd.u = double.Parse(k[7]);
                            break;

                        case "7":
                            odd.h1 = double.Parse(k[6]);
                            odd.a1 = double.Parse(k[7]);
                            break;

                        case "9":
                            odd.o1 = double.Parse(k[6]);
                            odd.u1 = double.Parse(k[7]);
                            break;
                        }
                        odds.Add(odd);
                    }
                }
                res.Data = odds;
            }
            catch (Exception ex)
            {
                res.Errors.Add("Convert Sbobet Running Odds Errors: " + ex.Message);
                res.Data = odds;
            }
            return(res);
        }
Beispiel #11
0
        static Task <int> UpdateGamesTask()
        {
            try
            {
                var files = new[] { "D:/Documents/BWay/rebetxmlfiles/GetSportEventsHalfTime.xml", "D:/Documents/BWay/rebetxmlfiles/GetSportEventsItalyEngland.xml" };

                var database = new ZeusDbContext();
                // start of files urls
                foreach (var file in files)
                {
                    var matches   = new List <Match>();
                    var matchodds = new List <MatchOdd>();
                    var xmldoc    = new XmlDocument();
                    xmldoc.Load(file);
                    var oddServiceNode = xmldoc.ChildNodes[1];
                    var resultsNode    = oddServiceNode.ChildNodes[1];

                    foreach (XmlNode eventNode in resultsNode)
                    {
                        var eventId = eventNode.ChildNodes[0].InnerText;
                        var unformattedStartDate = eventNode.ChildNodes[1].InnerText;
                        var startDateTime        = DateTime.Parse(unformattedStartDate);

                        var sportIdNode = eventNode.ChildNodes[2];
                        var sportId     = sportIdNode.InnerText;
                        var sportName   = (sportIdNode.Attributes != null) ? sportIdNode.Attributes["Name"].InnerText : String.Empty;

                        var leagueIdNode = eventNode.ChildNodes[3];
                        var leagueId     = leagueIdNode.InnerText;
                        var leagueName   = (leagueIdNode.Attributes != null) ? leagueIdNode.Attributes["Name"].InnerText : String.Empty;

                        var locationIdNode = eventNode.ChildNodes[4];
                        var locationId     = locationIdNode.InnerText;
                        var locationName   = (locationIdNode.Attributes != null) ? locationIdNode.Attributes["Name"].InnerText : String.Empty;

                        var lastUpdateTime = eventNode.ChildNodes[6].InnerText;
                        var homeTeamNode   = eventNode.ChildNodes[8];
                        var homeTeam       = (homeTeamNode.Attributes != null) ? homeTeamNode.Attributes["Name"].InnerText : String.Empty;

                        var awayTeamNode = eventNode.ChildNodes[9];

                        var awayTeam = awayTeamNode.Attributes != null
                            ? awayTeamNode.Attributes["Name"].InnerText
                            : String.Empty;

                        var outcomesNode = eventNode.ChildNodes[14];

                        Console.WriteLine("{0} -> {1} vs {2}", leagueName, homeTeam, awayTeam);
                        matches.Add(new Match
                        {
                            AwayTeamName      = awayTeam,
                            BetServiceMatchNo = Convert.ToInt32(eventId),
                            GameStatus        = "Not Started",
                            HomeTeamName      = homeTeam,
                            League            = leagueName,
                            RegistrationDate  = DateTime.Now,
                            ResultStatus      = 0,
                            StartTime         = startDateTime
                        });

                        if (!outcomesNode.HasChildNodes)
                        {
                            continue;
                        }

                        #region OutComes
                        foreach (XmlNode outcomeNode in outcomesNode.ChildNodes)
                        {
                            if (outcomeNode.Attributes == null)
                            {
                                continue;
                            }
                            var outcome = outcomeNode.Attributes["name"].InnerText;
                            //Console.WriteLine("{0} Odds", outcome);
                            var bookmakerNode = outcomeNode.ChildNodes[0];
                            var oddsNodes     = bookmakerNode.ChildNodes;

                            // Locate an out ome in the datbase with that particular name
                            var betcategory = new BetCategory
                            {
                                BetCategoryName = outcome
                            };

                            database.BetCategories.AddOrUpdate(bc => bc.BetCategoryName, betcategory);
                            database.SaveChanges();
                            switch (outcome)
                            {
                                #region 1x2 Odds
                            case "1X2":
                                foreach (XmlNode odd in oddsNodes)
                                {
                                    if (odd.Attributes == null)
                                    {
                                        continue;
                                    }
                                    var bet  = odd.Attributes["bet"].InnerText;
                                    var line = odd.Attributes["line"].InnerText;
                                    var unformattedLastUpdateTime = odd.Attributes["LastUpdate"].InnerText;
                                    var betoption = new BetOption
                                    {
                                        BetCategoryId = betcategory.BetCategoryId,
                                        Option        = bet,
                                        Line          = line
                                    };

                                    database.BetOptions.AddOrUpdate(
                                        bo => new { bo.Option, bo.BetCategoryId, bo.Line }, betoption);
                                    database.SaveChanges();
                                    var matchodd = new MatchOdd
                                    {
                                        BetServiceMatchNo = Convert.ToInt32(eventId),
                                        BetOptionId       = betoption.BetOptionId,
                                        LastUpdateTime    = DateTime.Parse(unformattedLastUpdateTime),
                                        Odd = Convert.ToDecimal(odd.Attributes["currentPrice"].InnerText)
                                    };
                                    matchodds.Add(matchodd);
                                }
                                break;
                                #endregion

                                #region Under/Over Odds
                            case "Under/Over":
                                foreach (XmlNode odd in oddsNodes)
                                {
                                    if (odd.Attributes == null)
                                    {
                                        continue;
                                    }
                                    var bet  = odd.Attributes["bet"].InnerText;
                                    var line = odd.Attributes["line"].InnerText;
                                    var unformattedLastUpdateTime = odd.Attributes["LastUpdate"].InnerText;
                                    var betoption = new BetOption
                                    {
                                        BetCategoryId = betcategory.BetCategoryId,
                                        Option        = bet,
                                        Line          = line
                                    };
                                    if (line != "0.5" && line != "1.5" && line != "2.5" && line != "3.5" &&
                                        line != "4.5" && line != "5.5" && line != "6.5")
                                    {
                                        continue;
                                    }
                                    database.BetOptions.AddOrUpdate(
                                        bo => new { bo.Option, bo.BetCategoryId, bo.Line }, betoption);
                                    database.SaveChanges();
                                    var matchodd = new MatchOdd
                                    {
                                        BetServiceMatchNo = Convert.ToInt32(eventId),
                                        BetOptionId       = betoption.BetOptionId,
                                        LastUpdateTime    = DateTime.Parse(unformattedLastUpdateTime),
                                        Odd = Convert.ToDecimal(odd.Attributes["currentPrice"].InnerText)
                                    };
                                    matchodds.Add(matchodd);
                                }
                                break;
                                #endregion

                                #region Double Chance Odds
                            case "Double Chance":
                                foreach (XmlNode odd in oddsNodes)
                                {
                                    if (odd.Attributes == null)
                                    {
                                        continue;
                                    }
                                    var bet  = odd.Attributes["bet"].InnerText;
                                    var line = odd.Attributes["line"].InnerText;
                                    var unformattedLastUpdateTime = odd.Attributes["LastUpdate"].InnerText;
                                    var betoption = new BetOption
                                    {
                                        BetCategoryId = betcategory.BetCategoryId,
                                        Option        = bet,
                                        Line          = line
                                    };

                                    database.BetOptions.AddOrUpdate(
                                        bo => new { bo.Option, bo.BetCategoryId, bo.Line }, betoption);
                                    database.SaveChanges();
                                    var matchodd = new MatchOdd
                                    {
                                        BetServiceMatchNo = Convert.ToInt32(eventId),
                                        BetOptionId       = betoption.BetOptionId,
                                        LastUpdateTime    = DateTime.Parse(unformattedLastUpdateTime),
                                        Odd = Convert.ToDecimal(odd.Attributes["currentPrice"].InnerText)
                                    };
                                    matchodds.Add(matchodd);
                                }
                                break;
                                #endregion

                                #region European Handicap
                            case "European Handicap":
                                foreach (XmlNode odd in oddsNodes)
                                {
                                    if (odd.Attributes == null)
                                    {
                                        continue;
                                    }
                                    var bet  = odd.Attributes["bet"].InnerText;
                                    var line = odd.Attributes["line"].InnerText;
                                    var unformattedLastUpdateTime = odd.Attributes["LastUpdate"].InnerText;
                                    var betoption = new BetOption
                                    {
                                        BetCategoryId = betcategory.BetCategoryId,
                                        Option        = bet,
                                        Line          = line
                                    };

                                    database.BetOptions.AddOrUpdate(
                                        bo => new { bo.Option, bo.BetCategoryId, bo.Line },
                                        betoption);
                                    database.SaveChanges();
                                    var matchodd = new MatchOdd
                                    {
                                        BetServiceMatchNo = Convert.ToInt32(eventId),
                                        BetOptionId       = betoption.BetOptionId,
                                        LastUpdateTime    = DateTime.Parse(unformattedLastUpdateTime),
                                        Odd = Convert.ToDecimal(odd.Attributes["currentPrice"].InnerText)
                                    };
                                    matchodds.Add(matchodd);
                                }
                                break;
                                #endregion

                                #region Both Teams To Score Odds
                            case "Both Teams To Score":
                                foreach (XmlNode odd in oddsNodes)
                                {
                                    if (odd.Attributes == null)
                                    {
                                        continue;
                                    }
                                    var bet  = odd.Attributes["bet"].InnerText;
                                    var line = odd.Attributes["line"].InnerText;
                                    var unformattedLastUpdateTime = odd.Attributes["LastUpdate"].InnerText;
                                    var betoption = new BetOption
                                    {
                                        BetCategoryId = betcategory.BetCategoryId,
                                        Option        = bet,
                                        Line          = line
                                    };

                                    database.BetOptions.AddOrUpdate(
                                        bo => new { bo.Option, bo.BetCategoryId, bo.Line }, betoption);
                                    database.SaveChanges();
                                    if (odd.Attributes == null)
                                    {
                                        continue;
                                    }
                                    var matchodd = new MatchOdd
                                    {
                                        BetServiceMatchNo = Convert.ToInt32(eventId),
                                        BetOptionId       = betoption.BetOptionId,
                                        LastUpdateTime    = DateTime.Parse(unformattedLastUpdateTime),
                                        Odd = Convert.ToDecimal(odd.Attributes["currentPrice"].InnerText)
                                    };
                                    matchodds.Add(matchodd);
                                }
                                break;
                                #endregion

                                #region Under/Over 1st Period
                            case "Under/Over 1st Period":
                                foreach (XmlNode odd in oddsNodes)
                                {
                                    if (odd.Attributes == null)
                                    {
                                        continue;
                                    }
                                    var bet  = odd.Attributes["bet"].InnerText;
                                    var line = odd.Attributes["line"].InnerText;
                                    var unformattedLastUpdateTime = odd.Attributes["LastUpdate"].InnerText;
                                    var betoption = new BetOption
                                    {
                                        BetCategoryId = betcategory.BetCategoryId,
                                        Option        = bet,
                                        Line          = line
                                    };

                                    database.BetOptions.AddOrUpdate(
                                        bo => new { bo.Option, bo.BetCategoryId, bo.Line }, betoption);
                                    database.SaveChanges();
                                    var matchodd = new MatchOdd
                                    {
                                        BetServiceMatchNo = Convert.ToInt32(eventId),
                                        BetOptionId       = betoption.BetOptionId,
                                        LastUpdateTime    = DateTime.Parse(unformattedLastUpdateTime),
                                        Odd = Convert.ToDecimal(odd.Attributes["currentPrice"].InnerText)
                                    };
                                    matchodds.Add(matchodd);
                                }
                                break;
                                #endregion

                                #region 1st Period Winner
                            case "1st Period Winner":
                                foreach (XmlNode odd in oddsNodes)
                                {
                                    if (odd.Attributes == null)
                                    {
                                        continue;
                                    }
                                    var bet  = odd.Attributes["bet"].InnerText;
                                    var line = odd.Attributes["line"].InnerText;
                                    var unformattedLastUpdateTime = odd.Attributes["LastUpdate"].InnerText;
                                    var betoption = new BetOption
                                    {
                                        BetCategoryId = betcategory.BetCategoryId,
                                        Option        = bet,
                                        Line          = line
                                    };

                                    database.BetOptions.AddOrUpdate(
                                        bo => new { bo.Option, bo.BetCategoryId, bo.Line }, betoption);
                                    database.SaveChanges();
                                    var matchodd = new MatchOdd
                                    {
                                        BetServiceMatchNo = Convert.ToInt32(eventId),
                                        BetOptionId       = betoption.BetOptionId,
                                        LastUpdateTime    = DateTime.Parse(unformattedLastUpdateTime),
                                        Odd = Convert.ToDecimal(odd.Attributes["currentPrice"].InnerText)
                                    };
                                    matchodds.Add(matchodd);
                                }
                                break;
                                #endregion
                            }
                        }
                        #endregion
                    }
                    // end of for each for file or url

                    try
                    {
                        const int chunkSize    = 100;
                        var       totalMatches = matches.Count;
                        var       chunksToSave = (totalMatches % chunkSize) > 0 ? (totalMatches / chunkSize) + 1 : totalMatches / chunkSize;
                        for (var i = 0; i < chunksToSave; i++)
                        {
                            var chunk     = matches.Skip(i * chunkSize).Take(chunkSize);
                            var startTime = DateTime.Now;
                            database.Matches.AddOrUpdate(m => m.BetServiceMatchNo, chunk.ToArray());
                            database.SaveChanges();
                            var endTime  = DateTime.Now;
                            var timeSpan = endTime - startTime;
                            Console.WriteLine("Matches in Chunk {0} Updated Successfully in {1} Seconds", i + 1, timeSpan.Seconds);
                        }

                        Console.WriteLine("Matches Updated Successfully");
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Error updating games: {0}.", ex.Message);
                    }
                    try
                    {
                        const int chunkSize      = 100;
                        var       totalMatchOdds = matchodds.Count;
                        var       chunksToSave   = (totalMatchOdds % chunkSize) > 0
                            ? (totalMatchOdds / chunkSize) + 1
                            : totalMatchOdds / chunkSize;

                        for (var i = 0; i < chunksToSave; i++)
                        {
                            var chunk     = matchodds.Skip(i * chunkSize).Take(chunkSize);
                            var startTime = new DateTime();
                            database.MatchOdds.AddOrUpdate(key => new { key.BetServiceMatchNo, key.BetOptionId }, chunk.ToArray());
                            database.SaveChanges();
                            var endTime  = new DateTime();
                            var timeSpan = endTime - startTime;
                            Console.WriteLine("MatchOdds in Chunk {0} Updated Successfully in {1} Seconds", i + 1, timeSpan.Seconds);
                        }
                        Console.WriteLine("All MatchOdds Updated Successfully");
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Error updating odds: {0}.", ex.Message);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception: " + ex.Message);
            }
            Console.ReadLine();
            return(Task.FromResult(0));
        }