Exemplo n.º 1
0
        public static List<LeagueTable> Get(LegaueTableResults Result)
        {
            if (ConfigurationManager.ConnectionStrings["DefaultConnection"] != null)
            {
                var table = new List<LeagueTable>();
                using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString))
                {
                    string sql = string.Format("SELECT * FROM {0} ORDER BY {1}", "vLadderTable", Result.ActiveResultType.Selector);
                    SqlDataAdapter da;

                    da = new SqlDataAdapter(sql, con);
                    DataSet ds = new DataSet();
                    da.Fill(ds);
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        table.Add(new LeagueTable()
                        {
                            Name = dr["Name"].ToString(),
                            Matchs = int.Parse(dr["Matchs"].ToString()),
                            Win = int.Parse(dr["Win"].ToString()),
                            Draw = int.Parse(dr["Draw"].ToString()),
                            Lost = int.Parse(dr["Lost"].ToString()),
                            GamesWon = int.Parse(dr["GamesWon"].ToString()),
                            GamesLost = int.Parse(dr["GamesLost"].ToString()),
                            GamesDiff = int.Parse(dr["GamesDiff"].ToString()),
                            Points = int.Parse(dr["Points"].ToString()),
                            WinPercentage = int.Parse(dr["WinPercentage"].ToString())
                        });
                    }
                }
                return table;
            }

            return null;
        }
        public ActionResult Index(LegaueTableResults Model)
        {
            ViewBag.Title = "The League table";
            ViewBag.Message = "Here are the current standings.";

            Model.Results = SquashLegaue.Repo.LeagueTableRepo.Get(Model);
            return View(Model);
        }