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("<h1> You have a new matchup</h1>");
                body.Append("<strong>Competitor: </strong>");
                body.Append(competitor.TeamCompeting.TeamName);
                body.AppendLine();
                body.AppendLine();
                body.AppendLine("Have a great time!");
                body.AppendLine("~Tournament Tracker");
            }
            else
            {
                subject = $"You have a bye.";

                body.AppendLine("Enjoy your Round Off.");
                body.AppendLine("~Tournament Tracker");
            }

            to = p.EmailAddress;

            EmailLogic.SendEmail(to, subject, body.ToString());
        }
        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 tournament

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


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

            body.AppendLine("<h1> We have a WINNER!</h1>");
            body.AppendLine("<p>Congratulations to our winner on a great tournament.</p>");
            body.AppendLine("<br / > ");
            if (winnerPrize > 0)
            {
                body.AppendLine($"<p>{winners.TeamName } will receive ${winnerPrize }</p>");
            }
            if (runnerUpPrize > 0)
            {
                body.AppendLine($"<p>{runnerup.TeamName } will receive ${ runnerUpPrize }</p>");
            }
            body.AppendLine("<p>Thanks for a great tournament everyone.</p>");
            body.AppendLine("~Tournament 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 tournament
            model.CompleteTournament();
        }
コード例 #3
0
ファイル: TournamentLogic.cs プロジェクト: bdan8/bajnoksag
        private static void CompleteTournament(TournamentModel model)
        {
            GlobalConfig.Connection.CompleteTournament(model);
            TeamModel winners = model.Rounds.Last().First().Winner;
            TeamModel looser  = model.Rounds.Last().First().Entries.Where(x => x.TeamCompeting != winners).First().TeamCompeting;

            decimal winnerPrize = 0;
            decimal looserPrize = 0;

            if (model.Prizes.Count > 0)
            {
                decimal totalIncome = model.teamModels.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.CalculatePrrizePayout(totalIncome);
                }
                if (secondPlacePrize != null)
                {
                    looserPrize = secondPlacePrize.CalculatePrrizePayout(totalIncome);
                }
            }

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

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

            body.AppendLine("<h1>We have a winner!</h1/");
            body.AppendLine($"Congratulations!");
            body.AppendLine("<br/>)");

            if (winnerPrize > 0)
            {
                body.AppendLine($"{winners.TeamName} will recive ${winnerPrize}");
            }
            if (looserPrize > 0)
            {
                body.AppendLine($"{looser.TeamName} will recive ${looserPrize}");
            }
            body.AppendLine("Have a great time!");
            body.AppendLine("~Tournament Tracke");

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

            foreach (TeamModel team in model.teamModels)
            {
                foreach (PersonModel person in team.TeamMembers)
                {
                    bcc.Add(person.EmailAddress);
                }
            }

            EmailLogic.SendEmail(new List <string> {
            }, bcc, subject, body.ToString());

            model.CompleteTournament();
        }