コード例 #1
0
        private static void AlertPersonToNewRound(PersonModel p, string teamName, MatchupEntryModel competitor)
        {
            if (p.EmailAddress.Length == 0)
            {
                return;
            }

            string        to      = "";
            string        subject = "";
            StringBuilder body    = new StringBuilder();

            if (competitor != null)
            {
                subject = $"You have a new matchup with {competitor.TeamCompeting.TeamName}";

                body.AppendLine("<hl>You have a NEW Matchup!</hl>");
                body.AppendLine("<p> </p>");
                body.AppendLine("<strong> Competitor: </strong>");
                body.AppendLine(competitor.TeamCompeting.TeamName);
                body.AppendLine("<p> </p>");

                body.AppendLine("Have a nice time!!!");
                body.AppendLine("<p> </p>");
                body.AppendLine("Tourname Tracker");
            }
            else
            {
                subject = $"You have a bye week this round";

                body.AppendLine("<p> </p>");
                body.AppendLine("<p> </p>");
                body.AppendLine("Have a nice day - See you in the <strong> next round </strong> !!!");
                body.AppendLine("<p> </p>");
                body.AppendLine("Tourname Tracker");
            }

            to = p.EmailAddress;

            EmailLogic.SendEmail(to, subject, body.ToString());
        }
コード例 #2
0
        private static void CompleteTournament(TournamentModel model)
        {
            GlobalConfig.Connection.CompleteTournament(model);
            TeamModel winners  = model.Rounds.Last().First().Winner;
            TeamModel runnerUp = model.Rounds.Last().First().Entries.Where(x => x.TeamCompeting != winners).First().TeamCompeting;

            decimal winnerPrize   = 0;
            decimal runnerUpPrize = 0;

            if (model.Prizes.Count > 0)
            {
                decimal    totalIncome      = model.EnteredTeams.Count * model.EntryFee;
                PrizeModel firstPlacePrize  = model.Prizes.Where(x => x.PlaceNumber == 1).FirstOrDefault();
                PrizeModel secondPlacePrize = model.Prizes.Where(x => x.PlaceNumber == 2).FirstOrDefault();

                if (firstPlacePrize != null)
                {
                    winnerPrize = firstPlacePrize.CalculatePrizePayout(totalIncome);
                }
                if (secondPlacePrize != null)
                {
                    runnerUpPrize = secondPlacePrize.CalculatePrizePayout(totalIncome);
                }
            }

            //Send Email to All!

            string        subject = "";
            StringBuilder body    = new StringBuilder();

            subject = $"In Tournament { model.TournamentName }, {winners.TeamName } has won! ";

            body.AppendLine("<hl>We have a Winner!</hl>");
            body.AppendLine("<p> Congrats!!! </p>");
            body.AppendLine("<br> :) </br>");

            if (winnerPrize > 0)
            {
                body.AppendLine($"<p> {winners.TeamName } will receive ${ winnerPrize } </p>");
            }
            if (runnerUpPrize > 0)
            {
                body.AppendLine($"<p> {runnerUp.TeamName } are the RunnerUp and will receive ${ runnerUpPrize } </p>");
            }

            body.AppendLine("<p></p>");
            body.AppendLine("<p></p>");
            body.AppendLine("<p>See you next time!!!</p>");
            body.AppendLine("Your Tourname Tracker");

            List <string> bcc = new List <string>();

            foreach (TeamModel t in model.EnteredTeams)
            {
                foreach (PersonModel p in t.TeamMembers)
                {
                    if (p.EmailAddress.Length > 0)
                    {
                        bcc.Add(p.EmailAddress);
                    }
                }
            }

            EmailLogic.SendEmail(new List <string>(), bcc, subject, body.ToString());
            //Complete TRNMT!

            model.CompleteTournament();
        }