Exemplo n.º 1
0
        private void CreateRows(List <ApplicationUser> users)
        {
            int row = 0;
            int col = 0;

            //ViewBag.EstimatedResults = new EstimatedResultForUser(EstimatedResultController.GetEstimatedResultModels());
            List <MatchModel>        matches   = MatchesController.GetMatches();
            Dictionary <int, string> helpUsers = new Dictionary <int, string>();

            //table header
            TipsTableRow header = new TipsTableRow(row);

            header.AddCell(col, string.Empty);
            col++;
            header.AddCell(col, string.Empty);
            col++;
            foreach (ApplicationUser user in users)
            {
                helpUsers.Add(col, user.Id);
                header.AddCell(col, user.UserName);
                col++;
            }
            this.rows.Add(header);
            row++;

            int colOverAll = users.Count + 2;

            //table data
            foreach (MatchModel match in matches)
            {
                col = 2;

                TipsTableRow tipRow = new TipsTableRow(row);
                tipRow.AddCell(0, match.TeamOne);
                tipRow.AddCell(1, match.TeamTwo);
                for (int i = 2; i < colOverAll; i++)
                {
                    string userId = helpUsers[i];
                    var    model  = EstimatedResultController.GetEstimatedResultModelForUserAndMatch(userId, match.Id);

                    string content = model != null?model.ToString() : string.Empty;

                    tipRow.AddCell(col, content);
                    col++;
                }
                this.rows.Add(tipRow);
                row++;
            }

            this.Rows    = this.rows.Count;
            this.Columns = colOverAll;
        }
Exemplo n.º 2
0
        public void CountPoints(Dictionary <int, ResultModel> newResults)
        {
            var rankingModels = RankingController.GetRanking();

            foreach (RankingModel rankingModel in rankingModels)
            {
                var userId = rankingModel.UserId;
                foreach (KeyValuePair <int, ResultModel> results in newResults)
                {
                    var estimatedResult = EstimatedResultController.GetEstimatedResultModelForUserAndMatch(userId, results.Key);
                    if (estimatedResult != null)
                    {
                        Evaulation evaulation = this.CompareResultAndEstimatedResult(results.Value, estimatedResult);
                        RankingController.UpdatePoints(userId, (int)evaulation);
                    }
                }
            }
        }