/// <summary> /// Generates the body of an email to alert participating players of their matchup /// for the new round, tailored to the team competing in the given matchup entry. /// </summary> /// <returns>A HTML-formatted string for the body of an email.</returns> private static string NewRoundEntryBody(MatchupModel matchup, MatchupEntryModel me) { StringBuilder body = new StringBuilder(); TeamModel competitor = matchup.Entries.Where(x => x.TeamCompeting != me.TeamCompeting).FirstOrDefault()?.TeamCompeting; if (competitor is null) { body.AppendLine("<h2>You have a bye week this round!</h2>"); body.AppendLine("<p>Enjoy your round off.</p>"); body.AppendLine("<p>~Tournament Tracker</p>"); } else { body.AppendLine("<h2>You have a new matchup!</h2>"); body.Append("<p><strong>Competitor: </strong>"); body.AppendLine(competitor.TeamName + "</p>"); body.AppendLine("<p>Have a great time.</p>"); body.AppendLine("<p>~Tournament Tracker</p>"); } return(body.ToString()); }
public TeamModel CreateTeam(TeamModel model) { using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnString(db))) { var p = new DynamicParameters(); p.Add("@TeamName", model.TeamName); p.Add("@Id", 0, dbType: DbType.Int32, direction: ParameterDirection.Output); connection.Execute("dbo.Teams_Insert", p, commandType: CommandType.StoredProcedure); model.Id = p.Get <int>("@Id"); foreach (PersonModel tm in model.TeamMembers) { p = new DynamicParameters(); p.Add("@TeamId", model.Id); p.Add("@PersonId", tm.Id); connection.Execute("dbo.TeamMembers_Insert", p, commandType: CommandType.StoredProcedure); } 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; // 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(); }
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(); }
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(); }
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(); }
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()); }
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(); }
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(); }
public void TeamComplete(TeamModel 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); } } //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(); }
public static List <MatchupModel> CreateRoundOne(TournamentModel tournament) { //create matchups //order our list randomly of teams getPowerseries(); double teamCount = 0; foreach (int count in power) { //if team count is in 2,4,8,16,32.... if (tournament.EnteredTeams.Count == count) { teamCount = count; break; } } List <TeamModel> byes = new List <TeamModel>(); //if team is not in 2,4,8,16,.... if (teamCount == 0) { for (int i = 0; i < power.Length; i++) { //if substraction is not minus then its the count of byes we need if (tournament.EnteredTeams.Count - power[i] > 0) { for (int j = 1; j <= tournament.EnteredTeams.Count - power[i]; j++) { byes.Add(new TeamModel { TeamName = "byes" + j }); } break; } } } List <MatchupModel> matchups = new List <MatchupModel>(); List <TeamModel> teams = new List <TeamModel>(); teams = tournament.EnteredTeams; if (byes.Count != 0) { teams.AddRange(byes); } while (teams.Count != 0) { int teamNum1 = new Random().Next(0, teams.Count); int teamNum2 = new Random().Next(0, teams.Count); if (teams.Count == 0) { break; } while (teamNum1 != teamNum2) { TeamModel team1 = teams[teamNum1]; TeamModel team2 = teams[teamNum2]; List <MatchupEntryModel> matchupentery = new List <MatchupEntryModel>(); matchupentery.Add(new MatchupEntryModel { Score = 0, TeamCompeting = team1 }); matchupentery.Add(new MatchupEntryModel { Score = 0, TeamCompeting = team2 }); matchups.Add(new MatchupModel { Entries = matchupentery, MatchupRound = 1 }); teams.Remove(team1); teams.Remove(team2); break; } } return(matchups); }
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(); }
public void TeamComplete(TeamModel model) { selectedTeams.Add(model); WireupLists(); }
/// <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; //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(); }
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 {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(); }
/// <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(); }