コード例 #1
0
        private static void AlertPersonToNewRound(PersonModel person, string teamCompetingTeamName, MatchupEntryModel matchupEntryModel)
        {
            if (person.Email.Length == 0)
            {
                return;
            }

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

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

                body.AppendLine("<h1>You have a new matchup</h1>");
                body.Append("<strong>Competitor: </strong>");
                body.Append(matchupEntryModel.TeamCompeting.TeamName);
                body.AppendLine();
                body.AppendLine();
                body.AppendLine("Have a nice time!");
                body.AppendLine("~Tournament Application");
            }
            else
            {
                subject = "You have a bye week this round";

                body.AppendLine("Enjoy your round off");
                body.AppendLine("~Tournament Application");
            }

            to = person.Email;
            EmailLogic.SendEmail(to, subject, body.ToString());
        }
コード例 #2
0
        private static void CompleteTournament(TournamentModel tournament)
        {
            GlobalConfig.Connections.CompleteTournament(tournament);
            TeamModel winner = tournament.Rounds.Last().First().Winner;
            TeamModel looser = tournament.Rounds.Last().First().Entries.First(i => i.TeamCompeting != winner).TeamCompeting;

            decimal winnerPrize = 0;
            decimal looserPrize = 0;

            if (tournament.Prizes.Count > 0)
            {
                decimal totalIncome = tournament.EnteredTeams.Count * tournament.EnrtyFee;

                PrizeModel firstPlace  = tournament.Prizes.FirstOrDefault(i => i.PlaceNumber == 1);
                PrizeModel secondPlace = tournament.Prizes.FirstOrDefault(i => i.PlaceNumber == 2);

                if (firstPlace != null)
                {
                    winnerPrize = firstPlace.CalculatePrize(totalIncome);
                }

                if (secondPlace != null)
                {
                    looserPrize = secondPlace.CalculatePrize(totalIncome);
                }
            }

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

            subject = $"In a tournament {tournament.TournamentName}, { winner.TeamName } is a winner.";

            body.AppendLine("<h1>Here is a winner!</h1>");
            body.Append("<p>Our Congrats! </p>");
            body.Append("<br />");
            if (winnerPrize > 0)
            {
                body.Append($"<p>Winner {winner.TeamName}, receive {winnerPrize}</p>");
            }
            if (looserPrize > 0)
            {
                body.Append($"<p>Looser {looser.TeamName}, receive {looserPrize}</p>");
            }
            body.AppendLine("<p>Thanks for gaming. GoodBye!</p>");
            body.AppendLine("~Tournament Application");

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

            foreach (TeamModel team in tournament.EnteredTeams)
            {
                foreach (PersonModel person in team.TeamMembers)
                {
                    if (person.Email.Length > 0)
                    {
                        bcc.Add(person.Email);
                    }
                }
            }
            EmailLogic.SendEmail(new List <string>(), bcc, subject, body.ToString());
            tournament.TournamentComplete();
        }