//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"));
        }
Пример #2
0
        // GET: RoundMatchups
        public async Task <IActionResult> Index()
        {
            int currentRound = RoundMatchupActions.GetLastRoundNo(_context);
            List <RoundMatchup> roundMatchups = await _context.RoundMatchups.Include(r => r.PlayerOne).Include(r => r.PlayerTwo).Where(r => r.RoundNo == currentRound).OrderByDescending(r => r.PlayerOne.BattleScore).ToListAsync();

            return(View(roundMatchups));
        }
Пример #3
0
        // GET: RoundMatchups Results
        public ActionResult Index()
        {
            int lastRoundNo       = RoundMatchupActions.GetLastRoundNo(_context);
            var roundMatchups     = _context.RoundMatchups.Where(r => !(r is PairRoundMatchup)).Where(r => r.RoundNo == lastRoundNo).Include(r => r.PlayerOne).Include(r => r.PlayerTwo).ToList();
            var pairRoundMatchups = _context.PairRoundMatchups.Where(r => r.RoundNo == lastRoundNo).Include(r => r.PlayerOne).Include(r => r.PlayerTwo).Include(r => r.PlayerThree).Include(r => r.PlayerFour).ToList();


            return(View(roundMatchups.Union(pairRoundMatchups).OrderBy(r => r.RoundNo)));
        }
        // GET: RoundMatchups
        public async Task <IActionResult> Index()
        {
            int lastRoundNo = RoundMatchupActions.GetLastRoundNo(_context);
            //Get all rounds as list from database and then filter using the where clause (potentially inefficient but no time to sort out lazy loading issue)
            var roundMatchups     = _context.RoundMatchups.Where(r => !(r is PairRoundMatchup)).Where(r => r.RoundNo == lastRoundNo).Include(r => r.PlayerOne).Include(r => r.PlayerTwo).ToList();
            var pairRoundMatchups = _context.PairRoundMatchups.Where(r => r.RoundNo == lastRoundNo).Include(r => r.PlayerOne).Include(r => r.PlayerTwo).Include(r => r.PlayerThree).Include(r => r.PlayerFour).ToList();

            return(View(roundMatchups.Union(pairRoundMatchups)));
        }
        // GET: AdminMatchups
        public async Task <IActionResult> Index()
        {
            int lastRoundNo = RoundMatchupActions.GetLastRoundNo(_context);

            ViewData["Errors"]               = TempData["Errors"];
            ViewData["DuplicateOpponents"]   = TempData["DuplicateOpponents"];
            ViewData["OverallocatedPlayers"] = TempData["OverallocatedPlayers"];
            ViewData["UnallocatedPlayers"]   = TempData["UnallocatedPlayers"];

            var roundMatchups     = _context.RoundMatchups.Where(r => !(r is PairRoundMatchup)).Where(r => r.RoundNo == lastRoundNo).Include(r => r.PlayerOne).Include(r => r.PlayerTwo).ToList();
            var pairRoundMatchups = _context.PairRoundMatchups.Where(r => r.RoundNo == lastRoundNo).Include(r => r.PlayerOne).Include(r => r.PlayerTwo).Include(r => r.PlayerThree).Include(r => r.PlayerFour).ToList();

            return(View(roundMatchups.Union(pairRoundMatchups)));
        }
Пример #6
0
        // GET: AdminMatchups
        public async Task <IActionResult> Index(int?roundNumber)
        {
            int?   currentRound;
            string selectedRound;
            List <RoundMatchup>     roundMatchups     = new List <RoundMatchup>();
            List <PairRoundMatchup> pairRoundMatchups = new List <PairRoundMatchup>();

            if (roundNumber == 0)
            {
                roundMatchups = await _context.RoundMatchups.Include(r => r.PlayerOne).Include(r => r.PlayerTwo).OrderByDescending(r => r.PlayerOne.BattleScore).ToListAsync();

                selectedRound = "all";
            }
            else
            {
                if (roundNumber == null)
                {
                    currentRound = RoundMatchupActions.GetLastRoundNo(_context);
                }
                else
                {
                    currentRound = roundNumber;
                }
                roundMatchups = await _context.RoundMatchups.Where(r => !(r is PairRoundMatchup)).Include(r => r.PlayerOne).Include(r => r.PlayerTwo).Where(r => r.RoundNo == currentRound).ToListAsync();

                pairRoundMatchups = await _context.PairRoundMatchup.Where(r => r.RoundNo == currentRound).Include(r => r.PlayerOne).Include(r => r.PlayerTwo).Include(r => r.PlayerThree).Include(r => r.PlayerFour).ToListAsync();

                selectedRound = currentRound.ToString();
            }
            AdminViewModel avm = new AdminViewModel
            {
                RoundMatchup = pairRoundMatchups,
                NoOfRounds   = _context.RoundMatchups.Select(r => r.RoundNo).ToArray(),
                CurrentRound = selectedRound
            };

            //If there were no pair round matchups, instead send through the standard round matchups
            if (avm.RoundMatchup.Count() == 0)
            {
                avm.RoundMatchup = roundMatchups;
            }
            ViewData["DuplicatePlayers"]     = TempData["DuplicatePlayers"];
            ViewData["DuplicateOpponents"]   = TempData["DuplicateOpponents"];
            ViewData["OverallocatedPlayers"] = TempData["OverallocatedPlayers"];
            ViewData["UnallocatedPlayers"]   = TempData["UnallocatedPlayers"];

            return(View(avm));
        }
Пример #7
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"));
        }