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 = $"Igrate novu utakmicu sa { competitor.TeamCompeting.TeamName }";

                body.AppendLine("<h1>Igrate novu utakmicu!</h1>");
                body.Append("<strong>Protivnik: </strong>");
                body.AppendLine(competitor.TeamCompeting.TeamName);
                body.AppendLine();
                body.AppendLine();
                body.AppendLine(" ~ Organizator Turnira ~");
            }
            else
            {
                subject = "Nemate protivnika u ovoj rundi i automatski idete dalje.";

                body.AppendLine("Uzivajte u slobodnom vremenu");
                body.AppendLine();
                body.AppendLine("~ Organizator Turnira ~");
            }

            to = p.EmailAddress;

            EmailLogic.SendEmail(to, subject, body.ToString());
        }
        private static void NotifyPersonToMatchup(this PersonModel person, string tournamentName, int round, TeamModel team, TeamModel competitor)
        {
            if (string.IsNullOrEmpty(person.EmailAddress))
            {
                return;
            }

            string        toAddress = person.EmailAddress;
            string        subject   = "";
            StringBuilder body      = new StringBuilder();

            if (competitor != null)
            {
                subject = $"You have a new matchup with {competitor.TeamName}";
                body.AppendLine("<h1>You have a new matchup</h1>");
                body.Append("<strong>Competitor: </strong>");
                body.AppendLine(competitor.TeamName);
                body.AppendLine("\n\n");
                body.AppendLine("Have a great time!");
            }
            else
            {
                subject = "You have a bye week for this round";
                body.AppendLine("Enjoy your round off");
            }
            body.AppendLine("~Tournament Tracker");

            EmailLogic.SendEmail(toAddress, subject, body.ToString());
        }
Exemplo n.º 3
0
        private static void AlertPersonToNewRound(PersonModel member, MatchupEntryModel adversary)
        {
            if (member.EmailAddress.Length == 0)
            {
                return;
            }

            var to      = member.EmailAddress;
            var subject = "";
            var body    = new StringBuilder();

            if (adversary != null)
            {
                subject = $"You have a upcoming match against {adversary.TeamCompeting.TeamName}";

                body.AppendLine("You have a new matchup");
                body.Append("Adversary: ");
                body.AppendLine(adversary.TeamCompeting.TeamName);
                body.AppendLine();
                body.AppendLine();
                body.AppendLine("Good Match, have fun!");
            }
            else
            {
                subject = "You have a bye this round";

                body.AppendLine("Enjoy your round off!");
                body.AppendLine("Have fun!");
            }

            EmailLogic.SendEmail(to, subject, body.ToString());
        }
Exemplo n.º 4
0
        private static void AlertPersonToNewRound(PersonModel person, string teamName, MatchupEntryModel competitor)
        {
            if (person.EmailAddress.Length == 0)
            {
                return;
            }
            List <string> to      = new List <string>();
            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.AppendLine($"<strong>Competitor: {competitor.TeamCompeting.TeamName}</strong>");

                body.AppendLine("Have a great time");
                body.AppendLine("~Tournament Tracker");
            }
            else
            {
                subject = "You have a bye week this round.";
                body.AppendLine("Enjoy your round off");
                body.AppendLine("~Tournament Tracker");
            }

            to.Add(person.EmailAddress);


            EmailLogic.SendEmail(new List <string>(), to, subject, body.ToString());
        }
        /// <summary>
        /// Compose mail and send it.
        /// </summary>
        /// <param name="person">Person to whom will email be sent.</param>
        /// <param name="teamName">Name of the team he's playing for.</param>
        /// <param name="competitor">Team they are playing against.</param>
        private static void AlertPersonToNewRound(PersonModel person, string teamName, MatchupEntryModel competitor)
        {
            if (person.EmailAddress.Length == 0)
            {
                return;
            }

            string        to      = person.EmailAddress;
            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 week this round";
                body.AppendLine("Enjoy your round off");
                body.AppendLine("Tournament Tracker");
            }

            EmailLogic.SendEmail(to, subject, body.ToString());
        }
Exemplo n.º 6
0
        private static void AlertPersonToNewRound(PersonModel p, string teamName, MatchupEntryModel competitor)
        {
            // If there is no emailaddress, just return
            if (p.EmailAddress.Length == 0)
            {
                return;
            }

            string        toAddress = "";
            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.AppendLine("<p><strong>Competitor: ");
                body.AppendLine(competitor.TeamCompeting.TeamName);
                body.AppendLine("</strong></p>");
                body.AppendLine();
                body.AppendLine("<p>Have a great time!</p>");
                body.AppendLine("<h2>~Tournament Tracker<h2/>");
            }
            else
            {
                subject = $"You have a bye week this round";
                body.AppendLine("<h1>Enjoy your round off</h1>");
                body.AppendLine();
                body.AppendLine("<h2>~Tournament Tracker<h2/>");
            }

            toAddress = p.EmailAddress;

            EmailLogic.SendEmail(toAddress, subject, body.ToString());
        }
        private static void AlertPersonToNewRound(PersonModel p, string teamName, MatchupEntryModel competitor)
        {
            if (p.EmailAddress.Length == 0 || !p.EmailAddress.Contains("@") || !p.EmailAddress.Contains("."))
            {
                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("<br>");
                body.AppendLine("<br>");
                body.AppendLine("<p>Have a great time!</p>");
                body.AppendLine("~Tournament Tracker");
            }
            else
            {
                subject = "You have a bye this round";

                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("<p>  Congratulations to our winner on a great tournament </p>");
            body.AppendLine("<string> Competitor: </strong>");
            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("~TournamentTracker");

            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());

            model.CompleteTournament();
        }
Exemplo n.º 9
0
        private static void CompleteTournament(TournamentModel tournament)
        {
            GlobalConfig.Connections.CompleteTournament(tournament);

            // Announce tournament results and prize distributions
            MatchupModel lastMatchup = tournament.Rounds.Last().First();
            TeamModel    winner      = lastMatchup.Winner;
            TeamModel    runnerUp    = lastMatchup.Entries.Where(x => x.TeamCompeting != winner).First().TeamCompeting;
            string       subject     = $"{tournament.TournamentName} has concluded!";

            StringBuilder body = new StringBuilder();

            body.AppendLine("<h2>WE HAVE A WINNER!</h2>");
            body.AppendLine($"<p>Congratulations to <b>{winner.TeamName}</b> on a great tournament.</p>");
            body.AppendLine("<br>");

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

                if (firstPlacePrize != null)
                {
                    decimal winnerPrizeAmt = CalculatePayout(firstPlacePrize, totalIncome);
                    body.AppendLine($"<p>{winner.TeamName} will receive ${string.Format("{0:0.00}", winnerPrizeAmt)}!</p>");
                }

                if (secondPlacePrize != null)
                {
                    decimal runnerUpPrizeAmt = CalculatePayout(secondPlacePrize, totalIncome);
                    body.AppendLine($"<p>{runnerUp.TeamName} will receive ${string.Format("{0:0.00}", runnerUpPrizeAmt)}.</p>");
                }

                if (firstPlacePrize != null || secondPlacePrize != null)
                {
                    body.AppendLine("<br>");
                }
            }

            body.AppendLine("<p>Hope everyone had a great time.</p>");
            body.AppendLine("<p>~Tournament Tracker</p>");

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

            foreach (TeamModel t in tournament.EnteredTeams)
            {
                foreach (PersonModel player in t.TeamMembers)
                {
                    bcc.Add(player.Email);
                }
            }

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

            // Complete tournament
            tournament.CompleteTournament();
        }
Exemplo n.º 10
0
        private static void CompleteTournament(Tournament model)
        {
            GlobalConfig.Connection.CompleteTournament(model);
            Team        winners            = model.Rounds.Last().First().Winner;
            Team        runnerUp           = model.Rounds.Last().First().Entries.Where(t => t.TeamCompeting != winners).First().TeamCompeting;
            List <Team> teamsSortedByPlace = GetTeamsByPlace(model);
            decimal     winnerPrize        = 0;
            decimal     runnerUpPrize      = 0;

            if (model.Prizes.Count > 0)
            {
                Prize firstPlacePrize  = model.Prizes.Where(p => p.PlaceNumber == 1).FirstOrDefault();
                Prize secondPlacePrize = model.Prizes.Where(p => p.PlaceNumber == 2).FirstOrDefault();

                if (firstPlacePrize != null)
                {
                    winnerPrize = firstPlacePrize.CalculatePrizePayout(model.TotalIncome);
                }


                if (secondPlacePrize != null)
                {
                    runnerUpPrize = secondPlacePrize.CalculatePrizePayout(model.TotalIncome);
                }
            }

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


            subject = $"In {model.TournamentName} the winner is {winners.TeamName}!";
            body.AppendLine("<h1>We have a winner!</h1>");
            body.AppendLine("Congratulations to tournament champion!<br>");
            body.AppendLine("Prizes were assigned as followed:<br>");
            body.AppendLine(GeneratePrizesTable(model));
            body.AppendLine(GeneratePlacesTable(teamsSortedByPlace));
            body.AppendLine($"Thanks to all {model.TournamentName} competitors.");
            body.AppendLine("~Tournament Tracker");

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

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

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

            model.CompleteTournament();
        }
Exemplo n.º 11
0
        private static void AllertPersonToNewRound(PersonModel p, string teamName, MatchupEntryModel competitor)
        {
            if (p.EmailAddress.Length > 0)
            {
                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("~ContestWinner Project");
                }
                else
                {
                    subject = "You have a bye week this round.";

                    body.AppendLine("Enjoy your round off!");
                    body.AppendLine("~ContestWinner Project");
                }

                to = p.EmailAddress;

                EmailLogic.SendEmail(to, subject, body.ToString());
            }

            try
            {
                if (p.CellPhoneNumber.Length > 0)
                {
                    if (competitor != null)
                    {
                        SMSLogic.SendSMSMessage(p.CellPhoneNumber, $"You have a new matchup with { competitor.TeamCompeting.TeamName }");
                    }
                    else
                    {
                        SMSLogic.SendSMSMessage(p.CellPhoneNumber, $"You have a bye week for the first round.");
                    }
                }
            }
            catch
            {
            }
        }
        private static void CompleteTournament(this TournamentModel tournament)
        {
            GlobalConfig.Connection.DeactivateTournament(tournament);
            MatchupModel finalMatchup = tournament.Rounds.Last().Matchups.First();
            TeamModel    winner       = finalMatchup.Winner;
            TeamModel    runnerUp     = finalMatchup.Entries.First(e => e.TeamCompeting != winner).TeamCompeting;

            decimal winnerPrize   = 0;
            decimal runnerUpPrize = 0;

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

                PrizeModel firstPlacePrize  = tournament.Prizes.FirstOrDefault(p => p.PlaceNumber == 1);
                PrizeModel secondPlacePrize = tournament.Prizes.FirstOrDefault(p => p.PlaceNumber == 2);

                winnerPrize   = firstPlacePrize?.CalculatePrizePayout(totalIncome) ?? 0;
                runnerUpPrize = secondPlacePrize?.CalculatePrizePayout(totalIncome) ?? 0;
            }

            string        subject = $"In {tournament.TournamentName}, {winner.TeamName} has won!";
            StringBuilder body    = new StringBuilder();

            body.AppendLine("<h1>We have a Winner!</h1>");
            body.AppendLine("<p>Congratulations to out winner on a great tournament.</p>");
            body.AppendLine("<br />");

            if (winnerPrize > 0)
            {
                body.AppendLine($"<p>{winner.TeamName} will receive ${winnerPrize}</p>");
            }

            if (runnerUpPrize > 0)
            {
                body.AppendLine($"<p>{runnerUp.TeamName} will receive {runnerUpPrize} as runner up</p>");
            }

            body.AppendLine("<p>Thanks to everyone for participating!</p>");
            body.AppendLine("<p>~Tournament Tracker</p>");

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

            tournament.EnteredTeams.ForEach(et => et.TeamMembers.Where(mb => !string.IsNullOrEmpty(mb.EmailAddress)).ToList().ForEach(p => bcc.Add(p.EmailAddress)));

            EmailLogic.SendEmail(new List <string>(), bcc, subject, body.ToString());
        }
Exemplo n.º 13
0
        private static void AlertPersonToNewRound(PersonModel p, string teamName, MatchupEntryModel competitor)
        {
            if (p.EmailAddress.Length > 0)
            {
                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 week this round";

                    body.AppendLine("Enjoy toyr round off!");
                    body.AppendLine("`Tournament Tracker");
                }

                to = p.EmailAddress;

                EmailLogic.SendEmail(to, subject, body.ToString());
            }

            //if (p.CellphoneNumber.Length > 0)
            //{
            //    if (competitor != null)
            //    {
            //        SMSLogic.SendSMSMessage(p.CellphoneNumber, $"You have a new matchup with { competitor.TeamCompeting.TeamName }");
            //    }
            //    else
            //    {
            //        SMSLogic.SendSMSMessage(p.CellphoneNumber, $"You have a bye week for the first round");

            //    }
            //}
        }
        private static void AlertPersonToNewRound(PersonModel p, string teamName, MatchUpEntryModel competitor)
        {
            if (p.EmailAddress == null)
            {
                return;
            }

            if (p.EmailAddress.Length == 0)
            {
                return;
            }



            string        toAdress = "";
            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</h>");
                body.Append("<strong>Competetitor:<strong> ");
                body.Append(competitor.TeamCompeting.TeamName);
                body.AppendLine();
                body.AppendLine();
                body.AppendLine("have a great time!");
                body.AppendLine("tournamet tracker");
            }
            else
            {
                subject = "you have a bye week this round";

                body.AppendLine("injoy your round off");
                body.AppendLine("tournamet tracker");
            }

            toAdress = p.EmailAddress;


            EmailLogic.SendEmail(toAdress, subject, body.ToString());
        }
        private static void AlertPlayerToNewRound(PersonModel player, string teamName, MatchupEntryModel competingTeam)
        {
            if (player.EmailAddress.Length > 0)
            {
                string        to      = "";
                string        subject = "";
                StringBuilder body    = new StringBuilder();

                if (competingTeam != null)
                {
                    subject = $"You have a new game with { competingTeam.TeamCompeting.TeamName }!";
                    body.AppendLine("<h1>You have a new game ahead</h1>");
                    body.Append("<strong>Competitor: </strong>");
                    body.Append(competingTeam.TeamCompeting.TeamName);
                    body.AppendLine();
                    body.AppendLine();
                    body.AppendLine("Best of luck!");
                    body.AppendLine("~ Tournament Tracker");
                }
                else
                {
                    subject = "You have a bye week this round";
                    body.AppendLine("Rest up this week and prepare!");
                    body.AppendLine("~ Tournament Tracker");
                }

                to = player.EmailAddress;

                EmailLogic.SendEmail(to, subject, body.ToString());
            }

            if (player.CellPhoneNumber.Length > 0)
            {
                if (competingTeam != null)
                {
                    SMSLogic.SendSMSMessage(player.CellPhoneNumber, $"You have a new matchup with { competingTeam.TeamCompeting.TeamName }");
                }
                else
                {
                    SMSLogic.SendSMSMessage(player.CellPhoneNumber, "You have a bye week this round");
                }
            }
        }
Exemplo n.º 16
0
        private static void AlertUsersToCompletedTournament(this TournamentModel model,
                                                            TeamModel winner,
                                                            TeamModel runnerUp,
                                                            decimal winnerPrize,
                                                            decimal runnerUpPrize)
        {
            string        subject;
            StringBuilder body = new StringBuilder();

            subject = $"In { model.TournamentName }, { winner.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>{ winner.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>();

            model.EnteredTeams.ForEach(t =>
            {
                t.TeamMembers.ForEach(p =>
                {
                    if (p.Email.Length > 0)
                    {
                        bcc.Add(p.Email);
                    }
                });
            });

            EmailLogic.SendEmail(new List <string>(), bcc, subject, body.ToString());
        }
Exemplo n.º 17
0
        public static void AlertUsersToNewRound(this TournamentModel tournament)
        {
            int currRoundNum = GetCurrentRound(tournament);
            List <MatchupModel> currRound = tournament.Rounds.Where(x => x.First().MatchupRound == currRoundNum).First();

            // Alert every member competing in the current round of this tournament of their matchup
            foreach (MatchupModel matchup in currRound)
            {
                foreach (MatchupEntryModel me in matchup.Entries)
                {
                    string subject = $"Your Next {tournament.TournamentName} Matchup";
                    string body    = NewRoundEntryBody(matchup, me);

                    List <string> to = new List <string>();
                    me.TeamCompeting.TeamMembers.ForEach(x => to.Add(x.Email));

                    EmailLogic.SendEmail(to, subject, body);
                }
            }
        }
        private static void AlertPersonToNewRound(PersonModel person, string teamName, MatchupEntryModel competitor)
        {
            if (person.EmailAddress.Length > 0)
            {
                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 an enjoyable match");
                    body.AppendLine("~ Tournament Tracker ~");
                }
                else
                {
                    subject = "You have a bye week this round.";

                    body.AppendLine("Thank You, enjoy your round off");
                    body.AppendLine("~ Tournament Tracker ~");
                }


                to = person.EmailAddress;

                EmailLogic.SendEmail(to, subject, body.ToString());
            }

            if (person.CellphoneNumber.Length > 0)
            {
                TextingLogic.SendSMSMessage(person.CellphoneNumber, $"You have a new matchup with { competitor.TeamCompeting.TeamName }");
            }
        }
Exemplo n.º 19
0
        private static void AlertPersonToNewRound(PersonModel p, string teamName, MatchupEntryModel competitor)
        {
            if (p.EmailAddress.Length > 0 && GlobalConfig.AppKeyLookUp("communicationPreference") == "Email")
            {
                if (IsValidEmail(p.EmailAddress))
                {
                    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>"); // Similar to appending a new line = sb.AppendLine
                        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 week this round";

                        body.AppendLine("Enjoy your round off!");
                        body.AppendLine("~Tournament Tracker");
                    }
                    to = p.EmailAddress;

                    EmailLogic.SendEmail(to, subject, body.ToString());
                }
            }

            if (p.CellphoneNumber.Length > 0 && GlobalConfig.AppKeyLookUp("communicationPreference") == "SMS")
            {
                SMSLogic.SendSMSMessage(p.CellphoneNumber, $"You have a new matchup with {competitor.TeamCompeting.TeamName}");
            }
        }
        private static void AlertPersonToNewRound(PersonModel p, string teamName, MatchupEntryModel competitor)
        {
            if (p.EmailAddress.Length == 0)
            {
                return;
            }
            // string fromAddress = "";
            //List<string> to = new List<string>(); //if we need to send to multiple players
            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("Hava a great time!");
                body.AppendLine("~Tournament Tracker");
            }
            else
            {
                subject = "You have a bye week this round";

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

            // to.Add(p.EmailAddress);
            to = p.EmailAddress;
            //fromAddress = GlobalConfig.AppKeyLookup("senderEmail");

            EmailLogic.SendEmail(to, subject, body.ToString());
        }
        private static void AlterPersonToNewRound(PersonModel p, string teamName, MatchupEntryModel competitor)
        {
            // To validate email you can use regular Expression or regex
            if (p.EmailAddress.Length == 0)
            {
                // if there is no Email, then we dont do anything.
                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 week this round";
                body.AppendLine("Enjoy your rond off!");
                body.AppendLine("~ Tournament Tracker");
            }

            to = p.EmailAddress;


            EmailLogic.SendEmail(to, subject, body.ToString());
        }
        private static void AlertPersonToNewRound(PersonModel p, string teamName, MatchupEntryModel competitor)
        {
            if (p.EmailAddress.Length == 0)
            {
                return;
            }

            //string fromAddress = "";
            string to      = ""; //We can send the message more than to one person
            string subject = "";
            //string body = "";
            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: ");
                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 week this round";

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

            to = p.EmailAddress;

            EmailLogic.SendEmail(to, subject, body.ToString());
        }
Exemplo n.º 23
0
        private static void AlertPersonToNextRound(PersonModel p, string teamName, MatchupEntryModel competitor)
        {
            if (p.EmailAddress.Length == 0)
            {
                return;
            }

            string        toAddress = "";
            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("Prepare yourself.");
                body.AppendLine("~Tournament Tracker");
            }
            else
            {
                subject = "You have a bye week this round.";

                body.Append("Enjoy your round off!");
                body.AppendLine("~Tournament Tracker");
            }

            toAddress = p.EmailAddress;


            EmailLogic.SendEmail(toAddress, subject, body.ToString());
        }
Exemplo n.º 24
0
        private static void AlertPersonToNewRound(PersonModel p, string teamName, MatchupEntryModel competitor)
        {
            if (p.EmailAddress.Length == 0)
            {
                return;
            }

            //List<string> to = new List<string>();
            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("<p>Have a great Time!<p>");
                body.AppendLine("<p>~Tournament Tracker~<p>");
            }
            else
            {
                subject = "You have a bye week this round.";

                body.AppendLine("<p>Enjoy your round off<p>");
                body.AppendLine("~Tournament Tracker~");
            }

            to = p.EmailAddress;

            EmailLogic.SendEmail(to, subject, body.ToString());
        }
Exemplo n.º 25
0
        private static void AlertPersonToNewRound(Person p, string teamName, MatchupEntry matchupEntry)
        {
            if (p.EmailAddress.Length == 0)
            {
                return;
            }

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

            if (matchupEntry != null)
            {
                subject = $"You have matchup with { matchupEntry.TeamCompeting.TeamName }.";
                body.AppendLine("<h1>You have new matchup!</h1>");
                body.AppendLine("<strong>Competitor:");
                body.AppendLine(matchupEntry.TeamCompeting.TeamName);
                body.AppendLine();
                body.AppendLine();
                body.AppendLine("See you soon!");
                body.AppendLine("~Tournament Tracker");
            }
            else
            {
                subject = $"You have buy in this round.";
                body.AppendLine("<h1>You have a buy round this time!</h1>");
                body.AppendLine();
                body.AppendLine();
                body.AppendLine("See you in next round!");
                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);
                }
            }

            //Salje mail za kraj turnira
            string        subject = "";
            StringBuilder body    = new StringBuilder();

            subject = $"Turnir: { model.TournamentName } je osvojio tim: { winners.TeamName }";

            body.AppendLine("<h1>Imamo novog Pobjednika!</h1>");
            body.Append("<p>Pobjednik: </p>");
            body.AppendLine("<br />");

            if (winnerPrize > 0)
            {
                body.AppendLine($"<p> { winners.TeamName } sleduje nagrada u iznosu od: { winnerPrize } </p>");
                body.AppendLine();
            }

            if (runnerUpPrize > 0)
            {
                body.AppendLine($"<p> { runnerUp.TeamName } sleduje nagrada u iznosu od: { runnerUpPrize } </p>");
                body.AppendLine();
            }

            body.AppendLine();
            body.AppendLine("~ Organizator Turnira ~");

            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());

            //Zavrsi Turnir
            model.CompleteTournament();
        }
        /// <summary>
        /// Complete Tournament by sending emails to everyone about winners and prizes they got.
        /// Currently we are handling prizes for only first 2 places
        /// </summary>
        /// <param name="tournament"></param>
        private static void CompleteTournament(TournamentModel tournament)
        {
            GlobalConfig.Connection.CompleteTournament(tournament);
            TeamModel winners = tournament.Rounds.Last().First().Winner;
            TeamModel loser   = tournament.Rounds.Last().First().Entries.Where(x => x.TeamCompeting != winners).First().TeamCompeting;

            decimal winnerPrize = 0;
            decimal loserPrize  = 0;

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

                PrizeModel firstPlacePrize  = tournament.Prizes.Where(x => x.PlaceNumber == 1).FirstOrDefault();
                PrizeModel secondPlacePrize = tournament.Prizes.Where(x => x.PlaceNumber == 2).FirstOrDefault();

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

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

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

            body.AppendLine("<h1>We have a winner!</h1>");
            body.AppendLine("<p>Congratulations to our winner on the great tournament.</p>");
            body.AppendLine();

            if (winnerPrize > 0)
            {
                body.AppendLine($"<p>{winners.TeamName} will receive ${winnerPrize}</p>");
            }
            if (loserPrize > 0)
            {
                body.AppendLine($"<p>{loser.TeamName} will receive ${loserPrize}</p>");
            }
            body.AppendLine();
            body.AppendLine("<p>Thanks for a great tournament!</p>");
            body.AppendLine("Tournament Tracker");

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

            foreach (TeamModel team in tournament.EnteredTeams)
            {
                foreach (PersonModel person in team.TeamMembers)
                {
                    if (person.EmailAddress.Length > 0)
                    {
                        bcc.Add(person.EmailAddress);
                    }
                }
            }

            EmailLogic.SendEmail(new List <string>(), bcc, subject, body.ToString());
            tournament.CompleteTournament();
        }
        private static void CompleteTournament(TournamentModel 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 runnerPrize = 0;

            if (model.Prizes.Count > 0)
            {
                decimal totalIncome = model.EnterdTeams.Count * model.EntryFee;

                PrizeModel firstPlacePrize = model.Prizes.Where(x => x.PlaceNumber == 1).FirstOrDefault();

                PrizeModel SecendPlacePrize = model.Prizes.Where(x => x.PlaceNumber == 2).FirstOrDefault();

                if (firstPlacePrize != null)
                {
                    winnerPrize = firstPlacePrize.CalculatePrizePayout(totalIncome);
                }
                if (SecendPlacePrize != null)
                {
                    runnerPrize = SecendPlacePrize.CalculatePrizePayout(totalIncome);
                }
            }
            string        subject = "";
            StringBuilder body    = new StringBuilder();



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

            body.AppendLine("<h1>we have a winner</h>");
            body.AppendLine("<p>congratulations to our winner.</p> ");
            body.AppendLine("<br/>");

            if (winnerPrize > 0)
            {
                body.AppendLine($"<p> {winners.TeamName} will receive {winnerPrize}</p>");
            }
            if (runnerPrize > 0)
            {
                body.AppendLine($"<p> {runnerUp.TeamName} will receive {runnerPrize}</p>");
            }

            body.AppendLine("<p>thanks for a great tounrnament</p>");
            body.AppendLine("tournamet tracker");


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

            foreach (TeamModel t in model.EnterdTeams)
            {
                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 tounrament
            model.CompleteTounrnament();
        }
Exemplo n.º 29
0
        private static void CompleteTournament(TournamentModel model)
        {
            model.IsActive = false;
            GlobalConfig.Connection.CompleteTournament(model);

            // find the max round from all the rounds
            var result = from sublist in model.Rounds
                         select new { myMax = sublist.Max(x => x.MatchupRound) };
            int myMax = result.Max(x => x.myMax);

            // Rounds is list of list.
            // Get the first list that contains the list of matchups where one of them has max round as round
            // get that first matchup of that matchup list (there will always be only one)
            TeamModel winner = model.Rounds.Where(x => x.First().MatchupRound == myMax)
                               .First().First().Winner;
            TeamModel runnerUp = model.Rounds.Where(x => x.First().MatchupRound == myMax)
                                 .First().First().Entries.Where(x => x.TeamCompeting != winner).First().TeamCompeting;

            decimal winnerAmount   = 0;
            decimal runnerUpAmount = 0;

            if (model.Prizes.Count > 0)
            {
                decimal totalIncome = model.EnteredTeams.Count * model.EntryFee;

                PrizeModel winnerPrize   = model.Prizes.Where(x => x.PlaceNumber == 1).FirstOrDefault();
                PrizeModel runnerUpPrize = model.Prizes.Where(x => x.PlaceNumber == 2).FirstOrDefault();

                if (winnerPrize != null)
                {
                    winnerAmount = winnerPrize.calculatePrizePayout(totalIncome);
                }

                if (runnerUpPrize != null)
                {
                    runnerUpAmount = runnerUpPrize.calculatePrizePayout(totalIncome);
                }
            }

            // Send email to all tournament
            string        subject = "";
            StringBuilder body    = new StringBuilder();


            subject = $"In {model.TournamentName}, {winner.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 (winnerAmount > 0)
            {
                body.AppendLine($"<p>{winner.TeamName} will recieve ${winnerAmount}.</p>");
            }

            if (runnerUpAmount > 0)
            {
                body.AppendLine($"<p>{runnerUp.TeamName} will recieve ${runnerUpAmount}.</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());

            model.CompleteTournament();
        }
Exemplo n.º 30
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;
            // TODO: Limit the number of prizes to first and second
            // because third place is not easy to determine, probably use scores
            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 at completion of tournament with prize information
            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 \u20AC{ winnerPrize }</p>"); // The Euro sign hex code is u20AC
            }

            if (runnerUpPrize > 0)
            {
                body.AppendLine($"<p>{ runnerUp.TeamName } will receive \u20AC{ runnerUpPrize }</p>");
            }

            body.AppendLine("<p>Thanks for a great tournament everyone!</p>");
            body.AppendLine("<h2>~Tournament Tracker<h2/>");

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

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

            EmailLogic.SendEmail(new List <string>(), bccAddress, subject, body.ToString());

            model.CompleteTournament();
        }