Пример #1
0
 public PrizeModel CreatePrize(PrizeModel model)
 {
     model.id = 1;
     return(model);
 }
        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
        public static void CompleteTournament(TournamentModel model)
        {
            GlobalConfig.Connection.CompleteTournament(model);

            // Last round only has 1 matchup and we find the winner for that matchup
            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.EntreredTeams.Count * model.EntryFee;

                // First of Default means if you don't find it then make it default empty for the object
                // type , in this case NULL if this was an int variable it would be 0
                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($"<pr> {winners.TeamName} will receive ${ winnerPrize }</p>");
            }

            if (runnerUpPrize > 0)
            {
                body.AppendLine($"<pr> {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.EntreredTeams)
            {
                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();
        }
        private static void CompleteTournament(TournamentModel model)
        {
            TeamModel winners = model.Rounds.Last().First().Winner;
            //model.WinnerId = winners.Id;
            TeamModel runnerUp = model.Rounds.Last().First().Entries.Where(x => x.TeamCompeting != winners).First().TeamCompeting;

            model.DateFinished = DateTime.Now;
            model.Winner       = winners;

            GlobalConfig.Connection.CompleteTournament(model);

            decimal winnerPrize   = 0;
            decimal runnerUpPrize = 0;

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

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

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

            // Send email to all tournament.

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


            subject = $"In {model.TournamentName} {winners.TeamName} has won!";
            body.AppendLine("<h1>We have a WINNER!</h1>");
            body.Append("<P>Congratulations to our winner ou a great Tournament. </P>");
            body.AppendLine("<br/>");

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

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

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

            foreach (TeamModel t in model.EnteredTeams)
            {
                foreach (PersonModel p in t.TeamMembers)
                {
                    if (!string.IsNullOrWhiteSpace(p.EmailAddress))
                    {
                        bcc.Add(p.EmailAddress);
                    }
                }
            }


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

            //Complete Tournament
            //model.DateFinished = DateTime.Now;
            //model.Winner = winners;
            model.CompleteTournament();
        }
Пример #5
0
 public PrizeModel CreatePrize(PrizeModel model)
 {
     throw new NotImplementedException();
 }
        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);
                }
            }
            //Complete the tournament
            //string to = "";
            string subject = "";

            StringBuilder body = new StringBuilder();


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

            body.AppendLine("<h1>We have a Winner</h1>");
            body.AppendLine("<h6>Congratulations to the winners of this team</h6>");
            body.AppendLine(Environment.NewLine);

            if (winnerPrize > 0)
            {
                body.AppendLine($"{winners.TeamName} won this match and will recieve ${winnerPrize}");
            }

            if (runnerUpPrize > 0)
            {
                body.AppendLine($"{runnerUp.TeamName} is the runner up of this match and will recieve ${runnerUpPrize}");
            }
            body.AppendLine();
            body.AppendLine();
            body.AppendLine("Have an enjoyable match");
            body.AppendLine("~ Tournament Tracker ~");

            subject = "You have a bye week this round.";

            body.AppendLine("Thank You, for using out system");
            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();
        }
Пример #7
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);
                }
            }


            // TODO - Change it to message box

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

            MessageBox.Show($"In { model.TournamentName }, { winners.TeamName } has won !!!" +
                            $"Congratulation to winner on a great tournament.");

            if (winnerPrize > 0)
            {
                MessageBox.Show($"{ winners.TeamName } will receive Rs{ winnerPrize }");
            }
            if (runnerUpPrize > 0)
            {
                MessageBox.Show($"{ runnerUp.TeamName } will receive Rs{ runnerUpPrize }");
            }

            //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();
        }
        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.EntryFee * model.EnteredTeams.Count;

                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);
                    prizeWinner = winnerPrize.ToString();
                }

                if (secondPlacePrize != null)
                {
                    runnerUpPrize = secondPlacePrize.CalculatePrizePayout(totalIncome);
                    prizeRunnerUp = runnerUpPrize.ToString();
                }
            }

            winnerTeam     = winners.TeamName;
            runnerUpTeam   = runnerUp.TeamName;
            tournamentName = model.TournamentName;

            // Emailing feature currently disabled.



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

            //subject = $"{ winners.TeamName } has won the { model.TournamentName } tournament!";

            //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 playing!</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();
        }
Пример #9
0
        /// <summary>
        /// Completes the tournament.
        /// </summary>
        /// <param name="model">Tournament to complete.</param>
        private static void CompleteTournament(TournamentModel model)
        {
            GlobalConfig.Connection.CompleteTournament(model);
            TeamModel winner   = model.Rounds.Last().First().Winner;
            TeamModel runnerUp = model.Rounds.Last().First().Entries.Where(x => x.TeamCompeting != winner).First().TeamCompeting;

            decimal winnerPrize   = 0;
            decimal runnerUpPrize = 0;

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

                PrizeModel firstPlace  = model.Prizes.Where(x => x.PlaceNumber == 1).FirstOrDefault();
                PrizeModel secondPlace = model.Prizes.Where(x => x.PlaceNumber == 2).FirstOrDefault();

                if (firstPlace != null)
                {
                    winnerPrize = firstPlace.DeterminePrizePayOut(totalPrizeAmount);
                }

                if (secondPlace != null)
                {
                    runnerUpPrize = secondPlace.DeterminePrizePayOut(totalPrizeAmount);
                }
            }

            // Send email to all tournament
            string subject = "";

            StringBuilder sb = new StringBuilder();

            subject = $"{model.TournamentName} has completed. {winner.TeamName} has won!";

            sb.AppendLine("<h1>WE HAVE A WINNER!</h1>");
            sb.AppendLine("<p>Congratulations to our winner on a great tournament.</p>");
            sb.AppendLine("<br />");

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

            if (runnerUpPrize > 0)
            {
                sb.AppendLine($"<p>{runnerUp.TeamName} will recieve ${runnerUpPrize}</p>");
            }

            sb.AppendLine(", Thank you for competing!");
            sb.AppendLine("~ Tournament Tracker / SM");

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

            Email.SendEmail(new List <string>(), bcc, subject, sb.ToString());

            // Complete tournament.
            model.CompleteTournament();
        }
 public PrizeModel CreatePrize(PrizeModel model)
 {
     return(model);
 }
Пример #11
0
 public PrizeModel CreatePrize(PrizeModel model)
 {
     // TODO - Create method to save new prize in db.
     model.Id = 1;
     return(model);
 }