예제 #1
0
        public SeasonTableModelView(Season season, IQueryable<Comment> Comments, Player CurrentPlayer)
        {
            SeasonEnd = season.SeasonEnd;
            SeasonStarts = season.SeasonStarts;

            //get active players
            Rows = season.GetActivePlayers().Select(p => new SeasonTablePlayerRow(p, season.GetPlayerPoints(p), season))
                .OrderByDescending(x => x.TotalPoints).ToArray();

            ColumnNames = season.Weeks.WeeksSoFar().Select(x => x.WeekStarts.ToString("dd MMM")).ToArray();

            //comments
            CommentModel = new CommentingViewModel(8, season.Id, Comments, CurrentPlayer);
        }
예제 #2
0
        public ResultTableModelView(Season currentSeason, Player currentLoggedInPlayer, IEnumerable<Comment> Comments)
        {
            LoggedInPlayer = currentLoggedInPlayer;
            week = currentSeason.GetLastWeekSeason();
            MatchOfTheWeek = week.MatchOfTheWeek;
            ThisWeeksMatches = week.AllMatches().OrderBy(m => m.MatchDate.Value);

            var LeaguePlayers = currentSeason.GetActivePlayers();

            var PlayerPointsCollection = new Dictionary<SimplePlayer, List<int>>();

            foreach (var p in LeaguePlayers)
            {
                var playerLastWeekPredictions = currentSeason.GetPlayersPredictionsForLastWeek(p);

                //For each Match this week get the players point
                List<int> Points = new List<int>();
                foreach (var m in ThisWeeksMatches)
                {
                    //if user has predictions then get them and add them (this way if player has 5predictions
                    //and there was 8 matches we correctly fill in the 0 scoring matches
                    var Prediction = playerLastWeekPredictions.Where(pp => pp.Match == m).SingleOrDefault();
                    if(Prediction != null){
                        Points.Add(Prediction.PointsEarned());
                    }else{
                        Points.Add(0);
                    }
                }

                PlayerPointsCollection.Add(new SimplePlayer(p), Points);

            }

            PlayersPoints = PlayerPointsCollection;

            //comments
            CommentModel = new CommentingViewModel(7, week.Id, Comments.AsQueryable(), currentLoggedInPlayer);
        }
예제 #3
0
        public SeasonTableModelCaching(Season season)
        {
            SeasonEnd = season.SeasonEnd;
             SeasonStarts = season.SeasonStarts;
             SeasonId = season.Id;

             //get active players
             Rows = season.GetActivePlayers().Select(p => new SeasonTablePlayerRow(p, season.GetPlayerPoints(p), season))
                 .OrderByDescending(x => x.TotalPoints).ToArray();

             ColumnNames = season.Weeks.WeeksSoFar().Select(x => x.WeekStarts.ToString("dd MMM")).ToArray();
        }