Exemplo n.º 1
0
        public static async Task <List <League> > ScrapeAsync(HttpClient client)
        {
            var json = await ApiUtility.GetAsync(client, URL);

            if (json == null)
            {
                return(null);
            }


            var data = JsonConvert.DeserializeObject <MerrybetData>(json, Converter.Settings).Data.Where(x => x.SportName == CATEGORY_SOCCER);

            var leagues = new List <League>();

            foreach (var item in data)
            {
                if (item.CategoryName.ToLower().Contains("outrights") || item.CategoryName.ToLower().Contains("specials") || item.CategoryName.ToLower().Contains("matches") || item.CategoryName.ToLower().Contains("forecast") || item.CategoryName.ToLower().Contains("goalscorer") || item.CategoryName.ToLower().Contains("winner") || item.CategoryName.ToLower().Contains("match"))
                {
                    continue;
                }

                var country   = item.ParentName;
                var countryId = item.ParentCategory;

                var leagueName = item.CategoryName;
                var leagueId   = item.CategoryId;

                leagues.Add(new League {
                    Country = country, CountryId = countryId.ToString(), LeagueId = leagueId.ToString(), LeagueName = leagueName, Site = BetConstants.MERRYBETNAME
                });
            }

            return(leagues);
        }
Exemplo n.º 2
0
        public async Task <ActionResult> AddEdit(int?id)
        {
            var model = new TermModel();

            if (id.HasValue)
            {
                model = await ApiUtility.GetAsyncById <TermModel>(Services.Terms, id.Value);

                if (!model.IsNew)
                {
                    var project = await ApiUtility.GetAsyncById <ProjectModel>(Services.Projects, model.ProjectId);

                    if (project != null)
                    {
                        model.ProjectName = project.Name;
                        model.Projects.Add(project);
                    }
                }
            }
            else
            {
                var projects = await ApiUtility.GetAsync <ProjectModel>(Services.Projects);

                model.Projects.AddRange(projects);
            }

            return(View(model));
        }
Exemplo n.º 3
0
        public async Task <ActionResult> Edit()
        {
            var model = await ApiUtility.GetAsyncById <UserModel>(Services.Users, UserSession.UserId);

            var projects = await ApiUtility.GetAsync <ProjectModel>(Services.Projects);

            model.Projects.AddRange(projects);
            return(View(model));
        }
Exemplo n.º 4
0
        public static async Task <List <League> > ScrapeAsync(HttpClient client)
        {
            try
            {
                var json = await ApiUtility.GetAsync(client, URL);

                var data = JsonConvert.DeserializeObject <SportyBetData>(json, Converter.Settings);

                if (data == null)
                {
                    return(null);
                }


                var leagues = new List <League>();
                foreach (var cat in data.Data.SportList[0].Categories)
                {
                    (var country, var countryId) = (cat.Name, cat.Id);

                    if (cat.Tournaments == null)
                    {
                        continue;
                    }


                    foreach (var lg in cat.Tournaments)
                    {
                        (var leagueName, var leagueId) = (lg.Name, lg.Id);

                        leagues.Add(new League {
                            Country = country, CountryId = countryId.ToString(), LeagueId = leagueId.ToString(), LeagueName = leagueName, Site = BetConstants.SPORTYBETNAME
                        });
                    }
                }

                return(leagues);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                return(null);
            }
        }
Exemplo n.º 5
0
        public static async Task <List <League> > ScrapeAsync(HttpClient client)
        {
            var json = await ApiUtility.GetAsync(client, URL);

            var data = JsonConvert.DeserializeObject <_1XBetData>(json, Converter.Settings);

            if (data == null)
            {
                return(null);
            }

            var filteredData = data.Value.FirstOrDefault(x => x.N == CATEGORY_SOCCER);

            if (filteredData == null)
            {
                throw new Exception("No soccer category");
            }

            var leagues = new List <League>();

            foreach (var lg in filteredData.L)
            {
                if (lg.LL.ToLower().Contains("statistics") || lg.LL.ToLower().Contains("friendlies") || lg.LL.ToLower().Contains("special") || lg.LL.ToLower().Contains("specials"))
                {
                    continue;
                }

                (var country, var countryId, var leagueName, var leagueId) = (lg.Cn, lg.Ci, lg.LL, lg.Li);

                leagues.Add(new League {
                    Country = country, CountryId = countryId.ToString(), LeagueId = leagueId.ToString(), LeagueName = leagueName, Site = BetConstants.ONEXBETNAME
                });
            }

            return(leagues);
        }