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 AlertPersonToNewRound(PersonModel person, string teamName, MatchupEntryModel competitor) { if (person.EmailAddress.Length == 0) { return; } string to = ""; string subject = ""; StringBuilder body = new StringBuilder(); if (competitor != null) { subject = $"You have a new matchup with {competitor.TeamCompeting.TeamName}"; body.AppendLine($"<h1>You ({teamName}) have a new matchup</h1>"); body.Append(Environment.NewLine); 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"); } to = person.EmailAddress; EmailLogic.SendEmail(to, subject, body.ToString()); }
private static void AlertPersonToNewRound(PersonModel p, string teamName, MatchupEntryModel competitor) { if (p.Email.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.Append("<strong>Competitor: </string>"); 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 round this time"; body.AppendLine("Enjoy your round off"); body.AppendLine("~Tournament Tracker"); } to.Add(p.Email); EmailLogic.SendEmail(to, subject, body.ToString()); }
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()); }
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> /// 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) { 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(); }
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) { 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(); }
private static void CompleteTournament(TournamentModel model) { GlobalConfig.Connections.CompleteTournament(model); var lastMatchup = model.Rounds.Last().First(); var winner = lastMatchup.Winner; var runnerUp = lastMatchup.Entries.Where(x => x.TeamCompeting != winner).First().TeamCompeting; decimal winnerPrize = 0; decimal runnerUpPrize = 0; if (model.Prizes.Count > 0) { var totalIncome = model.EnteredTeams.Count * model.EntryFee; var firstPlacePrize = model.Prizes.Where(x => x.PlaceNumber == 1).FirstOrDefault(); var secondPlacePrize = model.Prizes.Where(x => x.PlaceNumber == 2).FirstOrDefault(); if (firstPlacePrize != null) { winnerPrize = firstPlacePrize.CaculatePrizePayout(totalIncome); } if (secondPlacePrize != null) { runnerUpPrize = secondPlacePrize.CaculatePrizePayout(totalIncome); } } // Send Email to all teams var subject = ""; var body = new StringBuilder(); subject = $"In { model.TournamentName } , { winner.TeamName } has won!"; body .AppendLine("<h1>We have a WINNER!</h1>") .AppendLine("<p>Congratulation to our winner on a great Tournament. </p>") .AppendLine("<br />"); if (winnerPrize > 0) { body.AppendLine($"<p> { winner.TeamName } wil receive Rs:{ winnerPrize } </p>"); } if (runnerUpPrize > 0) { body.AppendLine($"<p> { runnerUp.TeamName } wil receive Rs:{ runnerUpPrize } </p>"); } body .AppendLine("Have a great time!") .AppendLine("Tournament Tracker... "); var bcc = new List <string>(); foreach (var t in model.EnteredTeams) { foreach (var person in t.TeamMembers) { if (person.EmailAddress.Length > 0) { bcc.Add(person.EmailAddress); } } } EmailLogic.SendEmail(null, subject, body.ToString()); // Complete Tournament model.CompleteTournament(); }