Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
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 static bool HasCompletedPredictions(this Player query, Week week)
        {
            //TODO CURRENTLY this gets Current weeks predictions and takes in the weeks matches... it should get Predictions/Matches from same week

            //Does the players confirmed predictions count match that of week given matches
            return (query.GetPredictionsForThisWeek().Where(p => p.Confirmed).Count() >= week.LiveMatches().Count());
        }
Exemplo n.º 4
0
 public virtual void AddPrediction(Week week, PlayerPrediction prediction)
 {
     week.SubmitPrediction(prediction);
 }
Exemplo n.º 5
0
        private static string BuildWeekMatches(Week week)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("<table style='font-size:12px;border-collapse:collapse' cellspacing='5' cellpadding='5'>");
            sb.Append("<tr style='background:#FFFCD6'>");
            sb.Append("<th colspan='4'>Match</th>");
            sb.Append("<th>Rds</th>");
            sb.Append("</tr>");

            foreach(var m in week.Matches.OrderBy(m =>m.MatchDate)){

                if (m == week.MatchOfTheWeek)
                {
                    sb.Append("<tr style='background:#FFFCD6'>");
                }
                else
                {
                    sb.Append("<tr>");
                }
                sb.Append("<td>" + m.MatchDate.Value.ordinalDateMonth() + "</td>");
                sb.Append("<td>" + m.Boxers.First().NameLink + "</td>");
                sb.Append("<td>vs</td>");
                sb.Append("<td>" + m.Boxers.Last().NameLink + "</td>");
                if(m.Rounds>0){
                    sb.Append("<td>" + m.Rounds + "</td>");
                }else{
                    sb.Append("<td>N/A</td>");
                }
                sb.Append("</tr>");
            }
            sb.Append("</table>");
            return sb.ToString();
        }
Exemplo n.º 6
0
 private static Week CreateWeek(DateTime weekStart)
 {
     var week = new Week(weekStart);
     return week;
 }
Exemplo n.º 7
0
 public virtual int GetTotalPointsForAPlayersWeek(Player player, Week week)
 {
     return week.GetPlayerPredications().Where(pp => pp.Player.Id == player.Id).Sum(pp => pp.PointsEarned());
 }
Exemplo n.º 8
0
 public WeekPlayerScoreCard(Week week, IEnumerable<PlayerPrediction> predictions)
 {
     Week = week;
     Predictions = predictions;
 }