示例#1
0
        public BPLPlayerViewModel(IEnumerable<League> leagues, Season currentSeason, IEnumerable<PlayerPredictionSummary> predictions, IEnumerable<PlayerPredictionSummary> LastWeekPredictions, Player LoggedInPlayer, Week LastWeek)
        {
            LeagueSelections = leagues.ToDictionary((x => x.Name), x => x.Id.ToString());
            CurrentSeasonText = string.Format("{0} - {1} to {2}", currentSeason.League.Name, currentSeason.SeasonStarts.ToLongDateString(), currentSeason.SeasonEnd.ToLongDateString());

            ThisWeek = currentSeason.GetCurrentWeekSeason();

            if (predictions != null)
            {
                PredictionsWithOutComes = predictions.Where(x => x.HasOutcome).OrderBy(y=>y.MatchDate);
                PredictionUpComingMatches = predictions.Where(x => !x.HasOutcome).OrderBy(y => y.MatchDate);
                ThisWeeksMotWId = ThisWeek != null && ThisWeek.MatchOfTheWeek != null ? ThisWeek.MatchOfTheWeek.Id : 0;
            }
            if (LastWeekPredictions != null)
            {
                PredictionsOfPreviousWeek = LastWeekPredictions.OrderBy(y => y.MatchDate);

                LastWeeksMotWId = LastWeek != null && LastWeek.MatchOfTheWeek != null ? LastWeek.MatchOfTheWeek.Id : 0;
            }

            //Build Players Table
            Points = currentSeason.Weeks.WeeksSoFar().Select(w => currentSeason.GetTotalPointsForAPlayersWeek(LoggedInPlayer, w)).ToList();
            WeekNames = currentSeason.Weeks.WeeksSoFar().Select(x => x.WeekStarts.Day.ordinalNum() + " " + x.WeekStarts.ToString("MMM")).ToArray();

            AllPredictionsConfirmed = ThisWeek != null ? LoggedInPlayer.HasCompletedPredictions(ThisWeek) : true;
        }
        public PlayerDashBoardViewModel(IEnumerable<League> leagues, Season currentSeason, IEnumerable<PlayerPredictionSummary> predictions, IEnumerable<PlayerPredictionSummary> LastWeekPredictions, Player playerProfile, Week LastWeek, Boolean IsViewingMyOwnPage, IQueryable<Notification> repnotifications)
        {
            LeagueSelections = leagues.ToDictionary((x => x.Name), x => x.Id.ToString());
            CurrentSeasonText = string.Format("{0} - {1} to {2}", currentSeason.League.Name, currentSeason.SeasonStarts.ToLongDateString(), currentSeason.SeasonEnd.ToLongDateString());

            ThisWeek = currentSeason.GetCurrentWeekSeason();
            IsMyPage = IsViewingMyOwnPage;

            if (predictions != null)
            {
                PredictionsWithOutComes = predictions.Where(x => x.HasOutcome).OrderBy(y=>y.MatchDate);
                PredictionUpComingMatches = predictions.Where(x => !x.HasOutcome).OrderBy(y => y.MatchDate);
                ThisWeeksMotWId = ThisWeek != null && ThisWeek.MatchOfTheWeek != null ? ThisWeek.MatchOfTheWeek.Id : 0;
            }
            if (LastWeekPredictions != null)
            {
                PredictionsOfPreviousWeek = LastWeekPredictions.OrderBy(y => y.MatchDate);

                LastWeeksMotWId = LastWeek != null && LastWeek.MatchOfTheWeek != null ? LastWeek.MatchOfTheWeek.Id : 0;
            }

            //Build Players Table
            Points = currentSeason.Weeks.WeeksSoFar().Select(w => currentSeason.GetTotalPointsForAPlayersWeek(playerProfile, w)).ToList();
            WeekNames = currentSeason.Weeks.WeeksSoFar().Select(x => x.WeekStarts.Day.ordinalNum() + " " + x.WeekStarts.ToString("MMM")).ToArray();

            //set up notifications
            notifications = repnotifications.Take(3);

            AllPredictionsConfirmed = ThisWeek != null ? playerProfile.HasCompletedPredictions(ThisWeek) : true;
        }
示例#3
0
        public PredictionViewModel(Season currentSeason, Player currentLoggedInPlayer, IEnumerable<Comment> Comments)
        {
            LoggedInPlayer = currentLoggedInPlayer;

            Week week = currentSeason.GetCurrentWeekSeason();
            CurrentWeekText =  string.Format("This Week runs from {0} too {1}, This weeks cutoff for predictions is at {2} on the {3}",
                                week.WeekStarts.ordinalDateShortDay(),
                                week.WeekEnds.ordinalDateShortDay(),
                                week.WeekCutOff.ToString("hh:mm tt"),
                                week.WeekCutOff.ordinalDateShortDay());

            ThisWeeksMatches = week.AllMatches().OrderBy(m =>m.MatchDate.Value);

            MatchOfTheWeek = week.MatchOfTheWeek;

            var PPs = new Dictionary<Player, IEnumerable<PlayerPrediction>>();
            var PlayersWithCompletedPredictions = currentSeason.League.Players.Where(p => p.HasCompletedPredictions(week));
            foreach (var p in PlayersWithCompletedPredictions.OrderByDescending(x=>x.CurrentTotalPoints(currentSeason)))
            {
                PPs.Add(p, p.GetPredictionsForThisWeek().OrderBy(m => m.Match.MatchDate.Value));
            }

            PlayerPredictions = PPs;

            //comments
            CommentModel = new CommentingViewModel(7, week.Id, Comments.AsQueryable(), LoggedInPlayer);
        }
示例#4
0
        public static int SendPredictionsReminderEmail(Season season)
        {
            var StartTime = DateTime.Now;

            var thisWeek = season.GetCurrentWeekSeason();
            int EmailCount = 0;

            var PlayersNoPredictions = season.League.Players.Where(x => !x.HasCompletedPredictions(thisWeek)).ToList();

            //TODO: this will probably crash at the end/start of a season!
            foreach (var player in PlayersNoPredictions)
            {
                //need to change the week to last week or list of predictions
                var GetPlayersLastWeek = BuildPlayersLastWeekMatches(season, player);

                StringBuilder body = new StringBuilder();

                body.Append("Dear " + player.Name + "<br />");
                body.Append("<p>This is a last minute warning that you have yet to enter some or all of your predictions for this week.</p>");
                body.Append(string.Format("<h2>Get your predictions in today by <span style='color:red'>{0}</span>.</h2>", thisWeek.WeekCutOff.ToString("HH:mm")));
                body.Append("<h2>To add your predictions <a href='http://www.britboxing.co.uk/boxingpredictionleague/addprediction'>Click Here</a></h2>");
                body.Append("<br/><br/> Regards <br/><br/>Steve<br/> Boxing Prediction League Admin");

                //only send out first 3 if in test mode
                if (System.Configuration.ConfigurationSettings.AppSettings["LiveServer"] == "false" && EmailCount >= 3)
                {
                    //dont send out more then 3 emails in test mode
                }
                else
                {
                    //Send out email and incredment if successful
                    if (Send(body.ToString(), player.User.Email, "*****@*****.**", "Final Reminder - Get your predictions in"))
                    {
                        EmailCount += 1;
                    }
                }
            }

            BuildAndSendAdminEmail("Friday Reminder", EmailCount, StartTime, DateTime.Now);
            return EmailCount;
        }
示例#5
0
        public static int SendNewPredictionsEmail(Season season)
        {
            var StartTime = DateTime.Now;
            var ThisWeek = season.GetCurrentWeekSeason();

            //Get league and week matches tables
            var LeagueTable = BuildLeagueTable(season);
            var WeekTable = BuildWeekMatches(ThisWeek);

            //SeasonWeek Name
            var SeasonText = string.Format("{0}: Season running from {0} to {1}",
                season.League.Name,
                season.SeasonStarts.ordinalDateMonth(),
                season.SeasonEnd.ordinalDateMonth());

            var WeekText = string.Format("Weeks cut off date {0} at {1}", ThisWeek.WeekCutOff.ordinalDateMonth(), ThisWeek.WeekCutOff.ToShortTimeString());

            int EmailCount = 0;

            //TODO: this will probably crash at the end/start of a season!
            foreach (var player in season.GetLivePlayers())
            {
                //need to change the week to last week or list of predictions
                var GetPlayersLastWeek = BuildPlayersLastWeekMatches(season, player);

                StringBuilder body = new StringBuilder();

                body.Append("Dear " + player.Name + "<br />");

                body.Append("<p>Here are your results for the week just gone and the matches for this weeks predictions.</p>");

                if(!string.IsNullOrEmpty(LeagueTable)){
                    body.Append("<h2>League Table <a href='http://www.britboxing.co.uk/season'>View Online</a></h2/>");
                    body.Append(LeagueTable + "<br/>");
                }

                if (!string.IsNullOrEmpty(WeekTable))
                {
                    body.Append("<h2>This Weeks Matches <a href='http://www.britboxing.co.uk/boxingpredictionleague/addprediction'>Add Prediction</a></h2>");
                    body.Append(WeekTable + "<br/>");
                }

                if (!string.IsNullOrEmpty(GetPlayersLastWeek))
                {
                    //Build their last weeks outcome results table
                    body.Append("<h2>Your Last weeks score <a href='http://www.britboxing.co.uk/player'>View Dashboard</a></h2>");
                    body.Append(GetPlayersLastWeek + "<br/>");
                }

                //ending of email
                body.Append("<p>Remember to get your predictions in for the week cut off</p>");
                body.Append("<p>You can access your dashboard by clicking <a href='http://www.britboxing.co.uk/player'>here</a></p>");
                body.Append("<h3>" + WeekText + "</h3>");

                body.Append("<br/><br/> Regards <br/><br/>Steve<br/> Boxing Prediction League Admin");

                //only send out first 3 if in test mode
                if (System.Configuration.ConfigurationSettings.AppSettings["LiveServer"] == "false" && EmailCount >= 3)
                {
                    //dont send out more then 3 emails in test mode
                }
                else
                {
                    //Send out email and incredment if successful
                    if (Send(body.ToString(), player.User.Email, "*****@*****.**", string.Format("{0}: Results and the week of {0} matches", season.League.Name, ThisWeek.WeekStarts.ToLongDateString())))
                    {
                        EmailCount += 1;
                    }
                }
            }
            BuildAndSendAdminEmail("Monday Results and New Predictions", EmailCount, StartTime, DateTime.Now);

            return EmailCount;
        }