public int CompareTo(TeamsData t)
 {
     if (t == null)
     {
         return(1);
     }
     return(-this.hostTeam.GetTotalForWeek(weeks).CompareTo(t.hostTeam.GetTotalForWeek(weeks)));
 }
        public void TestTextWithoutMention()
        {
            var m = TeamsData.FromJsonString <Message>("{\"id\": \"mid\",\"roomId\": \"sid\",\"roomType\": \"group\",\"text\": \"test\",\"personId\": \"pid\",\"personEmail\": \"[email protected]\",\"html\": \"test\",\"created\": \"2018-06-01T05:51:39.879Z\"}");

            Assert.AreEqual("test", m.TextWithoutMention);

            var text = "test";

            m = TeamsData.FromJsonString <Message>(String.Format("{{\"id\": \"mid\",\"roomId\": \"sid\",\"roomType\": \"group\",\"text\": \"person {0}\",\"personId\": \"pid\",\"personEmail\": \"[email protected]\",\"html\": \"<p><spark-mention data-object-type=\\\"person\\\" data-object-id=\\\"pid2\\\">person</spark-mention> {1}</p>\",\"mentionedPeople\": [\"pid2\"],\"created\": \"2018-06-01T05:51:39.879Z\"}}", text, WebUtility.HtmlEncode(text)));
            Assert.AreEqual(text, m.TextWithoutMention);

            text = "te<>&st";
            m    = TeamsData.FromJsonString <Message>(String.Format("{{\"id\": \"mid\",\"roomId\": \"sid\",\"roomType\": \"group\",\"text\": \"person {0}\",\"personId\": \"pid\",\"personEmail\": \"[email protected]\",\"html\": \"<p><spark-mention data-object-type=\\\"person\\\" data-object-id=\\\"pid2\\\">person</spark-mention> {1}</p>\",\"mentionedPeople\": [\"pid2\"],\"created\": \"2018-06-01T05:51:39.879Z\"}}", text, WebUtility.HtmlEncode(text)));
            Assert.AreEqual(text, m.TextWithoutMention);
        }
        private void NextWeekClick(object sender, RoutedEventArgs e)
        {
            Trace.WriteLine("Weeks: " + weeks + " Total: " + game.TotalWeeks);
            if (weeks + 1 < game.TotalWeeks)
            {
                weeks += 1;
                Trace.WriteLine("Displayed Teams size: " + displayedTeams.Count + " Displayed Players size: " + displayedPlayers.Count);
                Trace.WriteLine("Teams items size: " + teamsDataGrid.Items.Count + " Displayed Players size: " + playersDataGrid.Items.Count);
                for (int i = 0; i < teamsDataGrid.Items.Count; i++) // Clear substitutes from last week
                {
                    TeamsData t = displayedTeams[i];
                    t.hostTeam.ClearSubs();
                    displayedTeams[i] = t;
                }

                for (int i = 0; i < teamsDataGrid.Items.Count; i++)
                {
                    TeamsData t = displayedTeams[i];
                    t.hostTeam.SubCheck(weeks); // check if we need to sub in free agents
                    t.teamScore            = t.hostTeam.GetTotalForWeek(weeks);
                    t.teamProgress         = "+" + t.hostTeam.GetPointsGainedForWeek(weeks);
                    t.weeks                = weeks; // Tracks weeks for compareto
                    teamsDataGrid.Items[i] = t;
                    displayedTeams[i]      = t;
                }

                for (int i = 0; i < playersDataGrid.Items.Count; i++)
                {
                    PlayersData t = displayedPlayers[i];
                    t.playerScore            = t.hostEmp.GetTotalForWeek(weeks);
                    t.playerProgress         = "+" + t.hostEmp.GetScoreOfWeek(weeks);
                    t.weeks                  = weeks; // Tracks weeks for compareto
                    playersDataGrid.Items[i] = t;
                    displayedPlayers[i]      = t;
                }

                // Sort teams and players based on score rankings
                displayedTeams.Sort();
                teamsDataGrid.Items.Clear();
                for (int i = 0; i < displayedTeams.Count; i++)
                {
                    displayedTeams[i].teamRank = i + 1;
                    teamsDataGrid.Items.Add(displayedTeams[i]);
                }

                displayedPlayers.Sort();
                playersDataGrid.Items.Clear();
                for (int i = 0; i < displayedPlayers.Count; i++)
                {
                    displayedPlayers[i].playerRank = i + 1;
                    playersDataGrid.Items.Add(displayedPlayers[i]);
                }

                playersDataGrid.Items.Refresh();
                teamsDataGrid.Items.Refresh();

                vL1.Add(new KeyValuePair <string, int>("Week" + (weeks + 1), displayedTeams[0].teamScore));
                vL2.Add(new KeyValuePair <string, int>("Week" + (weeks + 1), displayedTeams[1].teamScore));
                vL3.Add(new KeyValuePair <string, int>("Week" + (weeks + 1), displayedTeams[2].teamScore));
                vL4.Add(new KeyValuePair <string, int>("Week" + (weeks + 1), displayedTeams[3].teamScore));
                vL5.Add(new KeyValuePair <string, int>("Week" + (weeks + 1), displayedTeams[4].teamScore));
                vL6.Add(new KeyValuePair <string, int>("Week" + (weeks + 1), displayedTeams[5].teamScore));
                vL7.Add(new KeyValuePair <string, int>("Week" + (weeks + 1), displayedTeams[6].teamScore));
                vL8.Add(new KeyValuePair <string, int>("Week" + (weeks + 1), displayedTeams[7].teamScore));
                vL9.Add(new KeyValuePair <string, int>("Week" + (weeks + 1), displayedTeams[8].teamScore));
                vL10.Add(new KeyValuePair <string, int>("Week" + (weeks + 1), displayedTeams[9].teamScore));
                updateLineData();
                updateBarGraph();
                Trace.WriteLine("Next week...");
            }
        }
        private void PrevWeekClick(object sender, RoutedEventArgs e)
        {
            Trace.WriteLine("Weeks: " + weeks);
            if (weeks - 1 >= 0)
            {
                weeks -= 1;
                for (int i = 0; i < teamsDataGrid.Items.Count; i++) // Clear substitutes from last week
                {
                    TeamsData t = displayedTeams[i];
                    t.hostTeam.ClearSubs();
                    displayedTeams[i] = t;
                }

                for (int i = 0; i < teamsDataGrid.Items.Count; i++)
                {
                    TeamsData t = displayedTeams[i];
                    t.hostTeam.SubCheck(weeks); // check if we need to sub in free agents
                    t.teamScore            = t.hostTeam.GetTotalForWeek(weeks);
                    t.teamProgress         = "+" + t.hostTeam.GetPointsGainedForWeek(weeks);
                    t.weeks                = weeks; // Tracks weeks for compareto
                    teamsDataGrid.Items[i] = t;
                    displayedTeams[i]      = t;
                }

                for (int i = 0; i < playersDataGrid.Items.Count; i++)
                {
                    PlayersData t = displayedPlayers[i];
                    t.playerScore            = t.hostEmp.GetTotalForWeek(weeks);
                    t.playerProgress         = "+" + t.hostEmp.GetScoreOfWeek(weeks);
                    t.weeks                  = weeks; // Tracks weeks for compareto
                    playersDataGrid.Items[i] = t;
                    displayedPlayers[i]      = t;
                }

                // Sort teams and players based on score rankings
                displayedTeams.Sort();
                teamsDataGrid.Items.Clear();
                for (int i = 0; i < displayedTeams.Count; i++)
                {
                    displayedTeams[i].teamRank = i + 1;
                    teamsDataGrid.Items.Add(displayedTeams[i]);
                }

                displayedPlayers.Sort();
                playersDataGrid.Items.Clear();
                for (int i = 0; i < displayedPlayers.Count; i++)
                {
                    displayedPlayers[i].playerRank = i + 1;
                    playersDataGrid.Items.Add(displayedPlayers[i]);
                }

                playersDataGrid.Items.Refresh();
                teamsDataGrid.Items.Refresh();

                vL1.RemoveAt(weeks + 1);
                vL2.RemoveAt(weeks + 1);
                vL3.RemoveAt(weeks + 1);
                vL4.RemoveAt(weeks + 1);
                vL5.RemoveAt(weeks + 1);
                vL6.RemoveAt(weeks + 1);
                vL7.RemoveAt(weeks + 1);
                vL8.RemoveAt(weeks + 1);
                vL9.RemoveAt(weeks + 1);
                vL10.RemoveAt(weeks + 1);
                updateLineData();
                updateBarGraph();
                Trace.WriteLine("Previous week...");
            }
        }
 public int CompareTo(TeamsData t)
 {
     if (t == null)
         return 1;
     return -this.hostTeam.GetTotalForWeek(weeks).CompareTo(t.hostTeam.GetTotalForWeek(weeks));
 }