Пример #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 ActionResult Login()
        {
            string userId = User.Identity.GetUserId();

            if (!RankingController.IsUserSaved(userId))
            {
                RankingController.AddUser(userId);
            }

            return(RedirectToAction("Index", "Home"));
        }
Пример #3
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);
                    }
                }
            }
        }
Пример #4
0
        public ActionResult DeleteUser(string userId, string userName)
        {
            log.Info($"Deleting user with userNAme: {userName}");

            RankingController.DeleteUser(userId);
            PayedController.RemoveUser(userId);
            EstimatedResultController.RemoveUser(userId);

            var user = HttpContext.GetOwinContext()
                       .GetUserManager <Identity.ApplicationUserManager>()
                       .Users.First(x => x.Id.Equals(userId));

            HttpContext.GetOwinContext()
            .GetUserManager <Identity.ApplicationUserManager>()
            .Delete(user);

            return(RedirectToAction("Index", "Admin"));
        }