public void NotifyPlayersTest()
 {
     MatchupsToNotifyGetResult tm = new MatchupsToNotifyGetResult()
     {
         Id = 12,
         PlayerAEmail = "*****@*****.**",
         PlayerAId = new Guid("B306EEFB-8B00-44D5-BE41-18829CC0A131"),
         PlayerAName = "Pini Usha",
         PlayerBId = new Guid("2509148F-C595-4A7E-9800-ECBB371DB857"),
         PlayerBEmail = "*****@*****.**",
         PlayerBName = "Daniel Usha",
         TournamentId = new Guid("FFFE4BFF-871C-410B-8190-39954A77CDFA"),
         Round = 1,
         Start = DateTime.Now.AddDays(8),
         TournamentName = "Ping Pong",
         Locations = "Aquarium",
         OrganisationId = new Guid("57baf8c4-3524-4273-a12b-c6cea946e920") // visa cal
     };
     TournamentMatchupManager.NotifyPlayers(tm);
     //Assert.Inconclusive("A method that does not return a value cannot be verified.");
 }
        public static void NotifyPlayers(MatchupsToNotifyGetResult tm)
        {
            string opponetName;
            string opponetEmail;
            string message;
            if (string.IsNullOrEmpty(tm.PlayerBName))
            {
                opponetName = "??";
                opponetEmail = string.Empty;
                message = "Congratulation you were choosen to move to the next round. Read more about <a href='http://en.wikipedia.org/wiki/Bye_(sports)'>bye in sport</a>";
            }
            else
            {
                opponetName = tm.PlayerBName;
                opponetEmail = tm.PlayerBEmail;
                message = string.Empty;
            }
            string templatePath = Path.Combine(ConfigurationManager.AppSettings["EmailTemplatePath"].ToString(), "NotifyPlayers.htm");
            string matchUpReadyTemplate = File.ReadAllText(templatePath);

            ListDictionary replacements = new ListDictionary();
            replacements.Add("<% PlayerName %>", tm.PlayerAName);
            replacements.Add("<% TournamentName %>", tm.TournamentName);
            replacements.Add("<% Opponent %>", opponetName);
            replacements.Add("<% OpponentEmail %>", opponetEmail);
            replacements.Add("<% GameDate %>", string.Format("{0:f}", tm.Start));
            replacements.Add("<% Message %>", message);
            replacements.Add("<% TournamentId %>", tm.TournamentId.ToString());
            replacements.Add("<% OrgId %>", tm.OrganisationId.ToString());
            replacements.Add("<% PlayerId %>", tm.PlayerAId.ToString());
            replacements.Add("<% MatchupId %>", tm.Id.ToString());
            replacements.Add("<% Round %>", tm.Round.ToString());
            if (!string.IsNullOrEmpty(tm.Locations))
            {
                replacements.Add("<% Location %>", string.Format("[@{0}]", tm.Locations));
            }
            else
            {
                replacements.Add("<% Location %>", string.Empty);
            }
            SendEmail(replacements, matchUpReadyTemplate, tm.PlayerAEmail, "Game matchup");
            if (!string.IsNullOrEmpty(tm.PlayerBName))
            {
                replacements["<% PlayerName %>"] = tm.PlayerBName;
                replacements["<% PlayerId %>"] = tm.PlayerBId.ToString();
                replacements["<% Opponent %>"] = tm.PlayerAName;
                replacements["<% OpponentEmail %>"] = tm.PlayerAEmail;
                SendEmail(replacements, matchUpReadyTemplate, tm.PlayerBEmail, "Game matchup");
            }
        }
        public static void NotifyFinalMatchup(MatchupsToNotifyGetResult tm)
        {
            string templatePath = Path.Combine(ConfigurationManager.AppSettings["EmailTemplatePath"].ToString(), "FinalesNotify.htm");
            string matchUpReadyTemplate = File.ReadAllText(templatePath);

            ListDictionary replacements = new ListDictionary();
            replacements.Add("<% PlayerName %>", tm.PlayerAName);
            replacements.Add("<% TournamentName %>", tm.TournamentName);
            replacements.Add("<% Opponent %>", tm.PlayerBName);
            replacements.Add("<% GameDate %>", string.Format("{0:f}", tm.Start));
            replacements.Add("<% FinalesTitle %>", "Final Game");
            replacements.Add("<% TournamentId %>", tm.TournamentId.ToString());
            replacements.Add("<% OrgId %>", tm.OrganisationId.ToString());
            replacements.Add("<% Round %>", tm.Round.ToString());
            if (!string.IsNullOrEmpty(tm.Locations))
            {
                replacements.Add("<% Location %>", string.Format("[@{0}]", tm.Locations));
            }
            else
            {
                replacements.Add("<% Location %>", string.Empty);
            }
            List<Competitor> competitors = PlayersManager.GetPlayers(tm.TournamentId);
            string emails = competitors.Select(c => c.Email).Aggregate((c1, c2) => { return string.Format("{0},{1}", c1, c2); });

            SendEmail(replacements, matchUpReadyTemplate, emails, tm.TournamentName + " Final Game");
        }