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;
        }
Example #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;
        }