public ActionResult SetEstimatedResults() { if (DateTime.Now >= new DateTime(2020, 6, 12, 21, 0, 0)) { return(View("OverDeadlineView")); } if (EstimatedResultController.GetEstimatedResultModelsForUser(User.Identity.GetUserId()).Any()) { return(View("JustOnceView")); } try { ViewBag.Matches = MatchesController.GetMatches(); ViewBag.EstimatedResults = new EstimatedResultForUser (EstimatedResultController.GetEstimatedResultModelsForUser(User.Identity.GetUserId())); ViewBag.Message = "OK"; } catch (Exception ex) { ViewBag.Message = ex.Message; } return(View("SetResultsView")); }
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()); }
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; }
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); } } } }
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")); }
public ActionResult SubmitResults() { var len = Request.Form.GetValues("MatchId").Length; var num1 = Request.Form.GetValues("Num1"); var num2 = Request.Form.GetValues("Num2"); var mId = Request.Form.GetValues("MatchId"); for (var i = 0; i < len; i++) { int one = Int32.Parse(num1[i]); int two = Int32.Parse(num2[i]); int id = Int32.Parse(mId[i]); string userId = User.Identity.GetUserId(); EstimatedResultController.AddEstimatedResult(userId, id, one, two); } return(RedirectToAction("Index", "Home")); }