//Reset the matchups
        public ActionResult ResetRoundMatchups()
        {
            int     roundNo          = RoundMatchupActions.GetLastRoundNo(_context);
            Boolean pairRoundMatchup = false;

            foreach (RoundMatchup roundMatchup in _context.RoundMatchups.Include(r => r.PlayerTwo).Where(r => r.RoundNo == roundNo).ToList())
            {
                if (roundMatchup is PairRoundMatchup && roundMatchup.PlayerTwo != null)
                {
                    pairRoundMatchup = true;
                }

                _context.Remove(roundMatchup);
            }
            _context.SaveChanges();
            if (pairRoundMatchup == true)
            {
                if (RoundMatchupActions.GenerateNextPairRound(_context) == false)
                {
                    TempData["Errors"] = "There are no unique matchups left, manual selection will be required (Random Matchups have been allocated where opponents from last round are teammates)";
                }
            }
            else
            {
                if (RoundMatchupActions.GenerateNextRound(_context) == false)
                {
                    TempData["Errors"] = "There are no unique matchups left, manual selection will be required (Matchups are generated based on most evenly skilled players according to BattleScore, with no regard for previous opponents)";
                }
            }
            return(RedirectToAction(nameof(Index), "Admin"));
        }
        public ActionResult DisplayNextPairRound()
        {
            List <Player> activePlayers = _context.Players.Where(p => p.Active == true).Where(p => p.Bye == false).ToList();

            if ((activePlayers.Count() % 4) != 0)
            {
                TempData["Errors"] = "You are attempting to generate a round with a number of players indivisible by four, choose the players that should have a bye and retry";
                return(RedirectToAction(nameof(Index), "Players"));
            }
            if (RoundMatchupActions.GenerateNextPairRound(_context) == false)
            {
                TempData["Errors"] = "There are no unique matchups left, manual selection will be required (Random Matchups have been allocated where opponents from last round are teammates)";
            }
            return(RedirectToAction(nameof(Index), "Admin"));
        }
Example #3
0
        //Reset the matchups
        public ActionResult ResetRoundMatchups()
        {
            int     roundNo          = RoundMatchupActions.GetLastRoundNo(_context);
            Boolean pairRoundMatchup = false;

            foreach (RoundMatchup roundMatchup in _context.RoundMatchups.Where(r => r.RoundNo == roundNo).ToList())
            {
                if (roundMatchup is PairRoundMatchup)
                {
                    pairRoundMatchup = true;
                }
                _context.Remove(roundMatchup);
            }
            _context.SaveChanges();
            if (pairRoundMatchup == true)
            {
                RoundMatchupActions.GenerateNextPairRound(_context);
            }
            else
            {
                RoundMatchupActions.GenerateNextRound(_context);
            }
            return(RedirectToAction(nameof(Index), "Admin"));
        }
Example #4
0
 public ActionResult DisplayNextPairRound()
 {
     RoundMatchupActions.GenerateNextPairRound(_context);
     return(RedirectToAction(nameof(Index)));
 }