// GET: Admin/Tournament public ActionResult Index(int page = 1, int pageSize = 10) { var dao = new TournamentDao(); var model = dao.ListAllPaging(page, pageSize); return(View(model)); }
public void Update() { MatchDao MatchDao = new MatchDao(database); TestPlayerDao pdao = new TestPlayerDao(); TournamentDao td = new TournamentDao(database); var list = td.FindAll(); int tId = list[0].ID; PlayerDao pd = new PlayerDao(database); var plist = pd.FindAll(); int p1id = plist[0].ID; int p2id = plist[1].ID; int p3id = plist[2].ID; int p4id = plist[3].ID; Match m = new Match(p1id, p2id, p3id, p4id, tId, false); int id = MatchDao.Insert(m); Assert.IsNotNull(id); Match n = MatchDao.FindById(id); n.Finished = true; MatchDao.Update(n); Assert.IsTrue(MatchDao.FindById(id).Finished); }
public void IncrementValue() { TournamentDao td = new TournamentDao(database); var list = td.FindAll(); int tId = list[0].ID; Assert.IsNotNull(tId); PlayerDao pd = new PlayerDao(database); var plist = pd.FindAll(); int p1id = plist[0].ID; int p2id = plist[1].ID; int p3id = plist[2].ID; int p4id = plist[3].ID; Match m = new Match(p1id, p2id, p3id, p4id, tId, 1, 1, false); int i = dao.Insert(m); SocketObj obj = new SocketObj(); obj.match = i; obj.team = 1; int?i1 = m.ResultPointsPlayer1; BLMatch.IncrementValue(obj); Match m1 = dao.FindById(i); int? i2 = m1.ResultPointsPlayer1; Assert.AreEqual(i1, i2 - 1); }
public void InsertMatchs() { MatchDao MatchDao = new MatchDao(database); TestPlayerDao pdao = new TestPlayerDao(); TournamentDao td = new TournamentDao(database); var list = td.FindAll(); int tId = list[0].ID; PlayerDao pd = new PlayerDao(database); var plist = pd.FindAll(); int p1id = plist[0].ID; int p2id = plist[1].ID; int p3id = plist[2].ID; int p4id = plist[3].ID; Match m = new Match(p1id, p2id, p3id, p4id, tId, false); int stat1 = MatchDao.FindAll().Count; MatchDao.Insert(m); int stat2 = MatchDao.FindAll().Count; Assert.IsTrue(stat1 == stat2 - 1); }
public void TestMatchContructor() { TestPlayerDao pdao = new TestPlayerDao(); TournamentDao td = new TournamentDao(database); var list = td.FindAll(); int tId = list[0].ID; PlayerDao pd = new PlayerDao(database); var plist = pd.FindAll(); int p1id = plist[0].ID; int p2id = plist[1].ID; int p3id = plist[2].ID; int p4id = plist[3].ID; Match m = new Match(p1id, p2id, p3id, p4id, tId, false); Assert.AreEqual(p1id, m.Team1Player1); Assert.AreEqual(p2id, m.Team1Player2); Assert.AreEqual(p3id, m.Team2Player1); Assert.AreEqual(p4id, m.Team2Player2); Assert.AreEqual(tId, m.TournamentId); Assert.IsNull(m.ResultPointsPlayer1); Assert.IsNull(m.ResultPointsPlayer2); }
public void GetOneMatchByID() { MatchDao MatchDao = new MatchDao(database); TestPlayerDao pdao = new TestPlayerDao(); TournamentDao td = new TournamentDao(database); var list = td.FindAll(); int tId = list[0].ID; PlayerDao pd = new PlayerDao(database); var plist = pd.FindAll(); int p1id = plist[0].ID; int p2id = plist[1].ID; int p3id = plist[2].ID; int p4id = plist[3].ID; Match m = new Match(p1id, p2id, p3id, p4id, tId, false); int retValue = MatchDao.Insert(m); Match match = MatchDao.FindById(retValue); Assert.AreEqual(match.Team1Player1, p1id); Assert.AreEqual(match.Team1Player2, p2id); Assert.AreEqual(match.Team2Player1, p3id); Assert.AreEqual(match.Team2Player2, p4id); Assert.AreEqual(match.TournamentId, tId); Assert.IsNull(m.ResultPointsPlayer1); Assert.IsNull(m.ResultPointsPlayer2); }
public void CheckDeleteById() { MatchDao MatchDao = new MatchDao(database); TestPlayerDao pdao = new TestPlayerDao(); TournamentDao td = new TournamentDao(database); var list = td.FindAll(); int tId = list[0].ID; PlayerDao pd = new PlayerDao(database); var plist = pd.FindAll(); int p1id = plist[0].ID; int p2id = plist[1].ID; int p3id = plist[2].ID; int p4id = plist[3].ID; Match m = new Match(p1id, p2id, p3id, p4id, tId, false); int id = MatchDao.Insert(m); int stat1 = MatchDao.FindAll().Count; MatchDao.DeleteById(id); int stat2 = MatchDao.FindAll().Count; Assert.AreEqual(stat1, stat2 + 1); }
public void InsertTournaments() { TournamentDao dao = new TournamentDao(database); foreach (Tournament t in dataSource.GenerateTournaments()) { dao.Insert(t); } }
public static void Clear(IDatabase database) { PlayerDao p = new PlayerDao(database); TournamentDao t = new TournamentDao(database); MatchDao m = new MatchDao(database); StatisticDao s = new StatisticDao(database); s.DeleteAll(); Console.WriteLine("cleared statistics..."); m.DeleteAll(); Console.WriteLine("cleared matches..."); t.DeleteAll(); Console.WriteLine("cleared Tournaments..."); p.DeleteAll(); Console.WriteLine("cleared player..."); }
public IList <Tournament> GenerateTournaments() { Random rand = new Random(); PlayerDao playerdao = new PlayerDao(database); TournamentDao tournamentDao = new TournamentDao(database); List <Tournament> tournamentList = new List <Tournament>(); int counter = 0; foreach (DateTime day in EachDay(DateTime.Today.AddYears(-1), DateTime.Today.AddDays(-1))) { ++counter; tournamentList.Add(new Tournament("Tournament " + counter, day)); } return(tournamentList); }
public ActionResult Edit(GiaiDau giai) { if (ModelState.IsValid) { var dao = new TournamentDao(); bool result = dao.Update(giai); if (result) { return(RedirectToAction("Index", "Tournament")); } else { ModelState.AddModelError("", "Cập nhật giải đấu thất bại"); } } return(RedirectToAction("Index")); }
public ActionResult Create(GiaiDau idgiai) { if (ModelState.IsValid) { var dao = new TournamentDao(); long id = dao.Insert(idgiai); if (id > 0) { return(RedirectToAction("Index", "Tournament")); } else { ModelState.AddModelError("", "Thêm giải đấu thất bại"); } } return(View("Index")); }
public IList <Match> GenerateMatchs() { IList <Match> matchlist = new List <Match>(); TournamentDao tournamentDao = new TournamentDao(database); PlayerDao PlayerDao = new PlayerDao(database); IList <Tournament> tournamentList = tournamentDao.FindAll(); IList <Player> playerList = PlayerDao.FindAll(); foreach (Tournament t in tournamentList) { IList <Player> newList = ShuffleList <Player>(playerList); int i = 0; Random rand = new Random(); matchlist.Add(new Match(newList[i++].ID, newList[i++].ID, newList[i++].ID, newList[i++].ID, t.ID, rand.Next(0, 10), rand.Next(0, 10), true)); matchlist.Add(new Match(newList[i++].ID, newList[i++].ID, newList[i++].ID, newList[i++].ID, t.ID, rand.Next(0, 10), rand.Next(0, 10), true)); matchlist.Add(new Match(newList[i++].ID, newList[i++].ID, newList[i++].ID, newList[i++].ID, t.ID, rand.Next(0, 10), rand.Next(0, 10), true)); matchlist.Add(new Match(newList[i++].ID, newList[i++].ID, newList[i++].ID, newList[i++].ID, t.ID, rand.Next(0, 10), rand.Next(0, 10), true)); } return(matchlist); }
public void InsertMatchs() { TournamentDao tdao = new TournamentDao(database); int t = tdao.Insert(new Tournament("name", DateTime.Now)); PlayerDao pd = new PlayerDao(database); var plist = pd.FindAll(); int p1id = plist[0].ID; int p2id = plist[1].ID; int p3id = plist[2].ID; int p4id = plist[3].ID; Match m = new Match(p1id, p2id, p3id, p4id, t, false); int stat1 = dao.FindAll().Count; dao.Insert(m); int stat2 = dao.FindAll().Count; Assert.IsTrue(stat1 == stat2 - 1); }
public ActionResult Edit(long id) { var giai = new TournamentDao().ViewDetail(id); return(View(giai)); }