public void CheckUpdate() { Random rand = new Random(); int randVal = rand.Next(); DateTime day = RandomDay(); int res = dao.Insert(new Tournament("teamname" + randVal, day)); Tournament t = dao.FindById(res); t.Name = "new test name"; dao.Update(t); Tournament t2 = dao.FindById(res); Assert.IsTrue(t2.Name == "new test name"); Assert.IsTrue(t2.Timestamp == day); }
public HttpResponseMessage Update([FromBody] Tournament team, int id) { //if (Authentication.getInstance().isAuthenticateWithHeader(Request)) //{ ITournamentDao TournamentDao = DalFactory.CreateTournamentDao(database); Tournament t = new Tournament(id, team.Name, team.Timestamp); var tx = TournamentDao.FindByDay(t.Timestamp); if (tx.Count > 1 && tx.Any(x => x.ID == t.ID)) { return(Request.CreateResponse <bool>(HttpStatusCode.Conflict, false)); } else { TournamentDao.Update(t); return(Request.CreateResponse <bool>(HttpStatusCode.OK, true)); } //} //return new HttpResponseMessage(HttpStatusCode.Forbidden); }