public IHttpActionResult PuttblMatch(int id, tblMatch tblMatch) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != tblMatch.Id) { return(BadRequest()); } db.Entry(tblMatch).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!tblMatchExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GettblMatch(int id) { tblMatch tblMatch = db.tblMatches.Find(id); if (tblMatch == null) { return(NotFound()); } return(Ok(tblMatch)); }
public IHttpActionResult PosttblMatch(tblMatch tblMatch) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.tblMatches.Add(tblMatch); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = tblMatch.Id }, tblMatch)); }
public static int Delete(Guid id) { using (BoBEntities bob = new BoBEntities()) { tblMatch row = bob.tblMatches.FirstOrDefault(m => m.Id == id); if (row != null) { bob.tblMatches.Remove(row); } return(bob.SaveChanges()); } }
public IHttpActionResult DeletetblMatch(int id) { tblMatch tblMatch = db.tblMatches.Find(id); if (tblMatch == null) { return(NotFound()); } db.tblMatches.Remove(tblMatch); db.SaveChanges(); return(Ok(tblMatch)); }
public static int Update(Match match) { using (BoBEntities bob = new BoBEntities()) { tblMatch row = bob.tblMatches.FirstOrDefault(m => m.Id == match.Id); if (row != null) { row.Team1 = match.Player1.Id; row.Team2 = match.Player2.Id; row.Outcome = match.Winner.Id; row.ReportingPlayer = match.ReportingPlayer.Id; row.Round = match.Round; row.Division = match.Division; } return(bob.SaveChanges()); } }
public static Match LoadById(Guid id) { using (BoBEntities bob = new BoBEntities()) { tblMatch row = bob.tblMatches.FirstOrDefault(m => m.Id == id); return(new Match { Id = row.Id, Player1 = UserManager.LoadById(row.Team1), Player2 = UserManager.LoadById(row.Team2), Winner = UserManager.LoadById(row.Outcome), BracketId = row.BracketId, ReportingPlayer = UserManager.LoadById(row.ReportingPlayer), Round = row.Round, Division = row.Division }); } }
public static int Insert(Match match, Guid bracketid) { using (BoBEntities bob = new BoBEntities()) { tblMatch row = new tblMatch { Id = Guid.NewGuid(), Team1 = match.Player1.Id, Team2 = match.Player2.Id, Outcome = match.Winner.Id, BracketId = bracketid, ReportingPlayer = match.ReportingPlayer.Id, Round = match.Round, Division = match.Division }; match.Id = row.Id; bob.tblMatches.Add(row); return(bob.SaveChanges()); } }