Exemplo n.º 1
0
        /// <summary>
        /// Returns a fairly nice to use league table, transposing the most important
        /// data into a simple format
        /// </summary>
        /// <param name="LeagueID"></param>
        /// <returns></returns>
        public List <LeagueTableRecord> LeagueTable(int LeagueID)
        {
            List <LeagueTableRecord> Records = new List <LeagueTableRecord>();

            TeamAdapter ta = new TeamAdapter();

            foreach (Team t in ta.GetTeamsByLeague(LeagueID))
            {
                LeagueTableRecord ltr = new LeagueTableRecord();
                ltr.TeamID           = t.UniqueID;
                ltr.Name             = t.Name;
                ltr.SeasonStatistics = t.SeasonStatistics;

                Records.Add(ltr);
                ltr = null;
            }

            List <LeagueTableRecord> retVal = (from ltr in Records
                                               orderby ltr.SeasonStatistics.Points descending,
                                               ltr.SeasonStatistics.GoalDifference descending,
                                               ltr.SeasonStatistics.GoalsScored descending,
                                               ltr.Name ascending
                                               select ltr).ToList();


            return(retVal);
        }
Exemplo n.º 2
0
        private void UpdateLeagueTable()
        {
            // Headings[] should contain: Pos,Team,P,W,D,L,F,A,GD,Pts, or equivalent
            string[] Headings = LangResources.CurLang.LeagueTableHeadings.Split(new string[] { "," }, StringSplitOptions.None);

            LeagueAdapter la = new LeagueAdapter();

            lstLeague.Title   = la.GetLeague(SetupData.TeamData.LeagueID).Name;
            lstLeague.Columns = new List <ListColumn>()
            {
                new ListColumn(Headings[0], 75),
                new ListColumn(Headings[1], 300),
                new ListColumn(Headings[2], 75, HorizontalAlignment.Right),
                new ListColumn(Headings[3], 75, HorizontalAlignment.Right),
                new ListColumn(Headings[4], 75, HorizontalAlignment.Right),
                new ListColumn(Headings[5], 75, HorizontalAlignment.Right),
                new ListColumn(Headings[6], 75, HorizontalAlignment.Right),
                new ListColumn(Headings[7], 75, HorizontalAlignment.Right),
                new ListColumn(Headings[8], 75, HorizontalAlignment.Right),
                new ListColumn(Headings[9], 75, HorizontalAlignment.Right),
            };


            List <LeagueTableRecord> table = la.LeagueTable(SetupData.TeamData.LeagueID);

            List <ListRow> rows = new List <ListRow>();

            for (int i = 0; i < table.Count(); i++)
            {
                LeagueTableRecord t = table[i];

                rows.Add(new ListRow(t.TeamID, new List <object>()
                {
                    (i + 1).ToString(),
                    t.Name,
                    t.SeasonStatistics.GamesPlayed.ToString(),
                    t.SeasonStatistics.Won.ToString(),
                    t.SeasonStatistics.Drawn.ToString(),
                    t.SeasonStatistics.Lost.ToString(),
                    t.SeasonStatistics.GoalsScored.ToString(),
                    t.SeasonStatistics.GoalsConceded.ToString(),
                    t.SeasonStatistics.GoalDifference.ToString(),
                    t.SeasonStatistics.Points.ToString()
                }));
            }

            lstLeague.Rows               = rows;
            lstLeague.SelectionMode      = SelectMode.Callback;
            lstLeague.Callback_ItemClick = () => SetupData.Parent.ShowTeamScreen(lstLeague.SelectedID);
        }