public async Task <IActionResult> PutCompetition(int id, Competition competition) { if (id != competition.CompetitionID) { return(BadRequest()); } _context.Entry(competition).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CompetitionExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutGameStatus(int id, GameStatus gameStatus) { if (id != gameStatus.GameStatusID) { return(BadRequest()); } _context.Entry(gameStatus).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GameStatusExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutTable(int id, Table table) { if (id != table.TableID) { return(BadRequest()); } _context.Entry(table).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TableExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutRanking(int id, Ranking ranking) { if (id != ranking.RankingID) { return(BadRequest()); } _context.Entry(ranking).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RankingExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult> Post([FromBody] Player player) { await context.Players.AddAsync(player); await context.SaveChangesAsync(); return(NoContent()); }
private async Task <int> SubmitGame(Game game) { context.Games.Add(game); await context.SaveChangesAsync(); return(game.Id.Value); }
public async Task <IActionResult> PutUser(int id, User user) { User userindb = await _context.Users.FindAsync(user.UserID); if (id != user.UserID) { return(BadRequest()); } if (user.Password == null) { userindb.Password = "******"; } if (user.Password != userindb.Password) { userindb.HashSalt = Hashing.getSalt(); userindb.Password = Hashing.getHash(user.Password, userindb.HashSalt); } userindb.FirstName = user.FirstName; userindb.LastName = user.LastName; userindb.Email = user.Email; userindb.DateOfBirth = user.DateOfBirth; _context.Entry(userindb).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }