public void Database() { List <RoundsModel> rounds = _context.RoundsModel.ToList(); foreach (RoundsModel round in rounds) { _context.Remove(round); } List <RoundMatchup> roundmatchups = _context.RoundMatchups.ToList(); foreach (RoundMatchup roundmatchup in roundmatchups) { _context.Remove(roundmatchup); } _context.SaveChanges(); foreach (Player player in _context.Players.ToList()) { player.BattleScore = 0; player.SportsmanshipScore = 0; player.ArmyScore = 0; _context.SaveChanges(); } //PlayerActions.SetAllPlayerScores(_context); }
public void Database() { List <RoundMatchups> roundmatchups = _context.RoundMatchups.ToList(); foreach (RoundMatchups roundmatchup in roundmatchups) { _context.Remove(roundmatchup); } _context.SaveChanges(); SetAllPlayerBattleScores(); }
//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")); }
//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")); }