private void Get_Ligas() { // получить текущие лиги JToken leaguesJson = api.GetLeagues(); List <JToken> leagues = ApiModel.Parse(leaguesJson, "Sports League"); // записать их в свойство объекта LeaguesList foreach (JToken league in leagues) { LeagueModel leagueModel = new LeagueModel(); leagueModel.LeagueId = (long)league.SelectToken("LeagueId"); leagueModel.LeagueName = (string)league.SelectToken("LeagueName"); leagueModel.MarketTypeId = (int)league.SelectToken("MarketTypeId"); leagueModel.Since = (ulong)league.SelectToken("Since"); leagueModel.ListGames = new List <Game>(); leaguesList.Add(leagueModel); if (Ligs.IndexOf(leagueModel.LeagueName) < 0) // только новое имя лиги { Ligs.Add(leagueModel.LeagueName); } } // leaguesList.Clear(); // if read only ligas leaguesList.Sort((a, b) => a.LeagueName.CompareTo(b.LeagueName)); Ligs.Sort(); Lab.Content = "In Running" + " (" + Ligs.Count.ToString() + ")"; Ligas.Clear(); // new ? impossible rewrite for (int g = 0; g <= Ligs.Count - 1; g++) { Ligas.Add(new MyStr(Ligs[g])); } // return Ligass; }
private void Get_Ligas() { try { // получить текущие лиги JToken leaguesJson = api.GetLeagues(); List <JToken> leagues = ApiModel.Parse(leaguesJson, "Sports League"); // записать их в свойство объекта LeaguesList foreach (JToken league in leagues) { LeagueModel leagueModel = new LeagueModel(); leagueModel.LeagueId = (long)league.SelectToken("LeagueId"); leagueModel.LeagueName = (string)league.SelectToken("LeagueName"); leagueModel.MarketTypeId = (int)league.SelectToken("MarketTypeId"); leagueModel.Since = (ulong)league.SelectToken("Since"); leagueModel.ListGames = new List <Game>(); leaguesList.Add(leagueModel); } leaguesList.Sort((a, b) => a.LeagueName.CompareTo(b.LeagueName)); // сортировка } catch (Exception e) { MessageBox.Show(e.Message + " В реале пока лиг нет"); var err = new BaseUp().ConBase(); if (err == "") { // Base = new BaseUp().read_Base(Base, 3); if (UCTable.Base != null) { err = new BaseUp().write_Base(UCTable.Base, UCTable.user_id, UCTable.credit); if (err != "") { MessageBox.Show(err); } } } else { MessageBox.Show(err); } Environment.Exit(0); return; } }