Beispiel #1
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);
        }
 public NotificationModelView(IQueryable<Comment> Comments, Notification notification, Player CurrentPlayer)
 {
     body = notification.Body;
     subject = notification.Subject;
     CreatedAndBy = "Posted by " + notification.Player.Name + " @ " + notification.Created.ToString("dd MMMM yyyy @ hh:mm tt");
     //comments
     CommentModel = new CommentingViewModel(1, notification.Id, Comments, CurrentPlayer);
 }
        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);
        }
        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);
        }
 //used often for cache objects
 public SeasonTableModelView(IQueryable<Comment> Comments, Player CurrentPlayer, int SeasonId)
 {
     //comments
     CommentModel = new CommentingViewModel(8, SeasonId, Comments, CurrentPlayer);
 }