예제 #1
0
        public ActionResult Index()
        {
            if (!Request.IsAuthenticated)
            {
                return(View());
            }

            try
            {
                ViewBag.Matches          = MatchesController.GetMatches();
                ViewBag.EstimatedResults = new EstimatedResultForUser
                                               (EstimatedResultController.GetEstimatedResultModelsForUser(User.Identity.GetUserId()));
                ViewBag.Ranking = RankingController.GetRanking();
                ViewBag.Users   = new Users(HttpContext.GetOwinContext()
                                            .GetUserManager <Identity.ApplicationUserManager>()
                                            .Users.ToList());

                ViewBag.Message = "OK";
            }
            catch (Exception ex)
            {
                ViewBag.Message = ex.Message;
            }

            return(View());
        }
예제 #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);
                    }
                }
            }
        }